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.
Author |
Topic |
Rich Y
Starting Member
4 Posts |
Posted - 2007-07-17 : 04:27:58
|
I'm running a backup job that runs every 30mins. I give the file name the date via the following:DECLARE @FileName nvarchar(1000)SELECT @FileName = N'D:\BESMgmt_' + CONVERT(NVARCHAR, GETDATE(), 112) +'.BAK'SELECT @FileName BACKUP DATABASE [BESMgmt] TO DISK = @FileName WITH NOINIT , NOUNLOAD , NAME = N’BESMgmt’, NOSKIP , STATS = 10, NOFORMATWhat I'd like to do is add the time so the filename is more clear. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-07-17 : 04:38:18
|
[code]SELECT @FileName = N'D:\BESMgmt_' + replace(replace(replace(CONVERT(NVARCHAR(19), GETDATE(), 121), '-', ''), ':', ''), ' ', '_') + '.BAK'[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2007-07-17 : 04:44:37
|
How About:SELECT @FileName = N'D:\BESMgmt_' + CONVERT(NVARCHAR, GETDATE(), 112) + '_' + REPLACE(CONVERT(NVARCHAR, GETDATE(), 108),':','') + '.BAK' you would then get a string like : D:\BESMgmt_20070717_094336.BAK(run at 9:43 AM on 17/07/2007.-------------Charlie |
 |
|
Rich Y
Starting Member
4 Posts |
Posted - 2007-07-17 : 04:50:55
|
that looks pretty good. So this ran at 09.43 and 36 seconds? |
 |
|
Rich Y
Starting Member
4 Posts |
Posted - 2007-07-17 : 05:04:06
|
wicked, this is just want i needed.It seems so simple but I'd never even seen a SQL server before yesterday! |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-07-17 : 05:06:55
|
Good work. 1st thing you do before you start messing with it is to do backup !  KH[spoiler]Time is always against us[/spoiler] |
 |
|
Rich Y
Starting Member
4 Posts |
Posted - 2007-07-17 : 05:19:03
|
indeedy! |
 |
|
|
|
|
|
|