Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 [resolved] BACKUP DATABASE NAME FORMAT

Author  Topic 

cutepraba
Yak Posting Veteran

53 Posts

Posted - 2007-07-18 : 12:17:05
I have created a scheduled backup job in managemenet - > sql server agent -> jobs with the following variable.

In steps

Command

BACKUP DATABASE [MAINDB] TO DISK = N'E:\BKS\MAIN.bk' WITH INIT , NOUNLOAD , NAME = N'GOLDHISTORY backup', NOSKIP , STATS = 10, NOFORMAT

Now please help me how to save the DB file name in my own format

I need to save in my own format.

ie 'E:\BKS\MAIN+ 'ddmmmyyyy' + '-' 'hhmmss' + '.bk'

Thank you

____________
Praba

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-07-18 : 12:28:38
You can get date and time with getdate() function then take proper substring. Build backup command like following, change convertion style to what you like:


declare @file varchar(255)
select @file = 'E:\BKS\MAIN' + convert(char(8), getdate(), 112) + convert(char(2), datepart(hh, getdate()))+ convert(char(2), datepart(mi, getdate())) + convert(char(2), datepart(ss, getdate())) + '.bk'

BACKUP DATABASE [MAINDB] TO DISK = @file with ...
Go to Top of Page
   

- Advertisement -