时间:2021-07-01 10:21:17 帮助过:12人阅读
@Database是需要备份的数据库名,@Path是备份目录注意最后一个"/"
[vb] view plaincopy
use master go declare @Database nvarchar(256),@Path nvarchar(2048) select @Database=N‘AdventureWorks‘,@Path=N‘D:/TDDOWNLOAD/‘ declare @sql nvarchar(max) select @sql =N‘BACKUP DATABASE ‘+@Database+N‘ TO DISK = ‘‘‘+@Path+@Database+N‘_Full_‘+REPLACE(REPLACE(REPLACE(convert(nvarchar(30),getdate(),126),‘-‘,‘_‘),‘:‘,‘_‘),‘.‘,‘_‘)+N‘.bak‘‘ WITH NOFORMAT, INIT, NAME = N‘‘Full Database Backup‘‘, SKIP‘ exec (@sql) go
最后生成的备份文件
AdventureWorks_Full_2010_07_08T15_14_53_750.bak
sqlserver 备份数据库 按时间命名备份文件
标签:数据 varchar board ofo plain pre tdd path art