SQLServer 生成当前日期备份
生活随笔
收集整理的這篇文章主要介紹了
SQLServer 生成当前日期备份
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
DECLARE @DataBase NVARCHAR(64) DECLARE @strDate NVARCHAR(64) DECLARE @strPath NVARCHAR(512)
--備份采集配置數(shù)據(jù)庫 use?TestDB SET @DataBase='TestDB' set @strPath='E:\數(shù)據(jù)庫備份\' set @strDate = convert(NVARCHAR(19),getdate(),120) set @strDate = REPLACE(@strDate, ':' , '') set @strDate = REPLACE(@strDate, ' ' , '') set @strDate = REPLACE(@strDate, '-' , '') set @strPath = @strPath + @DataBase + '_' + @strDate + 'Auto.bak'
DUMP ?TRANSACTION ?TestDB WITH ?NO_LOG ? ? BACKUP LOG TestDB WITH NO_LOG DBCC SHRINKFILE (TestDB_Log, 1);
BACKUP DATABASE @DataBase TO DISK = @strPath WITH NOINIT , NOUNLOAD , NOSKIP , STATS = 10, NOFORMAT
--備份采集配置數(shù)據(jù)庫 use?TestDB SET @DataBase='TestDB' set @strPath='E:\數(shù)據(jù)庫備份\' set @strDate = convert(NVARCHAR(19),getdate(),120) set @strDate = REPLACE(@strDate, ':' , '') set @strDate = REPLACE(@strDate, ' ' , '') set @strDate = REPLACE(@strDate, '-' , '') set @strPath = @strPath + @DataBase + '_' + @strDate + 'Auto.bak'
DUMP ?TRANSACTION ?TestDB WITH ?NO_LOG ? ? BACKUP LOG TestDB WITH NO_LOG DBCC SHRINKFILE (TestDB_Log, 1);
BACKUP DATABASE @DataBase TO DISK = @strPath WITH NOINIT , NOUNLOAD , NOSKIP , STATS = 10, NOFORMAT
總結(jié)
以上是生活随笔為你收集整理的SQLServer 生成当前日期备份的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 博弈论相关知识
- 下一篇: SQL Server CLR 启用、部署