sql server备份

完全备份

declare @device varchar(255),@path varchar(255),@dbname varchar(255)
set @dbname='MIS_TEMP'
set @path='D:\project\eosserver\MIS_TEMP\Data\Backup\'
set @device=@path+@dbname+'_COMP_'+ convert(char(8),getdate(),112)+replace(convert(char(9),getdate(),114),':','')+'.bak'
BACKUP DATABASE @dbname TO DISK = @device with init

---完全备份,覆盖原有文件
---BACKUP DATABASE @dbname TO DISK = @device with init
---完全备份,在原有文件后面追加
---BACKUP DATABASE @dbname TO DISK = @device
---差异备份
---BACKUP DATABASE @dbname TO DISK = @device WITH DIFFERENTIAL

差异备份

declare @device varchar(255),@path varchar(255),@dbname varchar(255)
set @dbname='MIS_TEMP'
set @path='D:\project\eosserver\MIS_TEMP\Data\Backup\'
set @device=@path+@dbname+'_DIFF_'+ convert(char(8),getdate(),112)+replace(convert(char(9),getdate(),114),':','')+'.bak'
BACKUP DATABASE @dbname TO DISK = @device WITH DIFFERENTIAL

---完全备份,覆盖原有文件
BACKUP DATABASE @dbname TO DISK = @device with init
---完全备份,在原有文件后面追加
BACKUP DATABASE @dbname TO DISK = @device
----差异备份
BACKUP DATABASE @dbname TO DISK = @device WITH DIFFERENTIAL

posted @ 2013-12-23 10:14  青丝慕雪  阅读(381)  评论(0编辑  收藏  举报