Showing posts with label date. Show all posts
Showing posts with label date. Show all posts

Friday, February 24, 2012

Backup name with DateTime

I know how to backup my DB but i cant find a way to give a name with the current date time.

backup database SUSDB to disk = 'e:\backup\test_%date%.bak' with init;

Any idea how i can put the date to my file name?

thank you

You could use dynamic sq;:

declare

@.sql varchar(300)

set

@.sql='backup database SUSDB to disk = ''e:\backup\test_'+convert(varchar,getdate(),101)+'.bak'''

exec

(@.sql)

|||

You have two options modify the code in the first link for your needs or use the last two links to create one just for you. Hope this helps.

http://support.microsoft.com/kb/241397

Create custom code from these two.

http://forums.asp.net/thread/1049663.aspx

http://msdn2.microsoft.com/en-gb/library/aa259582(SQL.80).aspx

|||

Sorry i forgot to mention that i use my code inside SQL 2005 jobs,

so the backup is taken everynight

|||

So in your job step you should generate file name like was shown in one of previous steps, you can also if you wolud like to keep information how many backup you did in file name, modify backup step automatically on success to conatain current backup number. But for only modifing date, code from first answer should be helpful.

Good luck

Sunday, February 19, 2012

Backup logged time different

Hi,
I'm confused with what's being reported by SQL Server for the date of a
transacation log backup.
The backup had been taken on Jun 29, 2006, 12:14:20 p.m. This can be seen in
the Archive SQL Server Logs. However, when I double-click that entry, I get
the following result:
Log backed up: Database: ABC, creation date(time): 2006/05/31(09:21:36),
first LSN: 15407:479:1, last LSN: 15769:73834:1, number of dump devices: 1,
device information: (FILE=1, TYPE=DISK: {'R:\MSSQL.DATA\ABC.bak'}).
Note that the date-time for this entry is different. Any ideas why? I'm so
confused.
TIA.
Regards,The creation date in the log is the database creation date
and time, not the backup date and time.
-Sue
On Wed, 9 Aug 2006 07:50:02 -0700, Rob
<Rob@.discussions.microsoft.com> wrote:
>Hi,
>I'm confused with what's being reported by SQL Server for the date of a
>transacation log backup.
>The backup had been taken on Jun 29, 2006, 12:14:20 p.m. This can be seen in
>the Archive SQL Server Logs. However, when I double-click that entry, I get
>the following result:
>Log backed up: Database: ABC, creation date(time): 2006/05/31(09:21:36),
>first LSN: 15407:479:1, last LSN: 15769:73834:1, number of dump devices: 1,
>device information: (FILE=1, TYPE=DISK: {'R:\MSSQL.DATA\ABC.bak'}).
>Note that the date-time for this entry is different. Any ideas why? I'm so
>confused.
>TIA.
>Regards,

Backup logged time different

Hi,
I'm confused with what's being reported by SQL Server for the date of a
transacation log backup.
The backup had been taken on Jun 29, 2006, 12:14:20 p.m. This can be seen in
the Archive SQL Server Logs. However, when I double-click that entry, I get
the following result:
Log backed up: Database: ABC, creation date(time): 2006/05/31(09:21:36),
first LSN: 15407:479:1, last LSN: 15769:73834:1, number of dump devices: 1,
device information: (FILE=1, TYPE=DISK: {'R:\MSSQL.DATA\ABC.bak'}).
Note that the date-time for this entry is different. Any ideas why? I'm so
confused.
TIA.
Regards,The creation date in the log is the database creation date
and time, not the backup date and time.
-Sue
On Wed, 9 Aug 2006 07:50:02 -0700, Rob
<Rob@.discussions.microsoft.com> wrote:

>Hi,
>I'm confused with what's being reported by SQL Server for the date of a
>transacation log backup.
>The backup had been taken on Jun 29, 2006, 12:14:20 p.m. This can be seen i
n
>the Archive SQL Server Logs. However, when I double-click that entry, I get
>the following result:
>Log backed up: Database: ABC, creation date(time): 2006/05/31(09:21:36),
>first LSN: 15407:479:1, last LSN: 15769:73834:1, number of dump devices: 1,
>device information: (FILE=1, TYPE=DISK: {'R:\MSSQL.DATA\ABC.bak'}).
>Note that the date-time for this entry is different. Any ideas why? I'm so
>confused.
>TIA.
>Regards,