MS SQL Server 2000 按日期自動備份
ms sql server 2000
1.管理-作業-步驟-命令
DECLARE @strPath NVARCHAR(200)
set @strPath = convert(NVARCHAR(19),getdate(),120)
set @strPath = REPLACE(@strPath, ':' , '')
set @strPath = REPLACE(@strPath, '-' , '')
set @strPath = REPLACE(@strPath, ' ' , '')
set @strPath = 'D:\bak\' + 'DatabaseName_'+@strPath + '.bak'
BACKUP DATABASE [DatabaseName] TO DISK = @strPath WITH NOINIT ,
NOUNLOAD , NOSKIP , STATS = 10, NOFORMAT
2.參數
‘D:\bak\’改爲備份文件路徑
‘databasename’爲需備份的數據庫
3.生成備份文件名稱
DatabaseName_20190318224500.bak