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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2007-03-19 : 09:23:37
|
| Facundo writes "Hi: How can i add a timestamp to a generated file of a complete database backup, the idea is to archive full database backups using the date to identified it.Thanks a lot.FB" |
|
|
MohammedU
Posting Yak Master
145 Posts |
Posted - 2007-03-20 : 00:58:48
|
| SET NOCOUNT ON declare @Sys_Database Sysname, @BackupPath Sysname Declare @Vch_FileName Varchar(255), @Dt_DateAndTime Varchar(20), @Vch_SqlString Varchar(255) SELECT @Sys_Database = 'PUBS', @BackupPath = 'C:\' if right(@BackupPath,1) <> '\' select @BackupPath = @BackupPath+'\' select @Dt_DateAndTime = convert(char(8), getdate(), 112)+''+ Replace(convert(char(12), getdate(), 14),':','') SELECT @Vch_FileName = @BackupPath+replace (@@servername, '\', '$')+'_'+@Sys_Database+'_Full_' + @Dt_DateAndTime +'.BAK' BACKUP DATABASE @Sys_Database TO DISK = @Vch_FileName WITH INIT , STATS = 10 MohammedU |
 |
|
|
|
|
|
|
|