MS SQL Server 2000 按日期自動備份

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

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章