--备份数据库 --必须先创建Backup文件夹 DECLARE @name VARCHAR(250) SET @name = 'D:\Backup\DingHanECard_V2_ZQGDJ_' + CONVERT(VARCHAR(50), GETDATE(), 112) + '.bak' BACKUP DATABASE [DingHanECard_V2_ZQGDJ] TO DISK = @name WITH NOFORMAT, NOINIT, NAME = N'DingHanECard_V2_ZQGDJ-完整 数据库 备份', SKIP, NOREWIND, NOUNLOAD
--数据库还原 DECLARE @name VARCHAR(250) SET @name = 'D:\Backup\DingHanECard_V2_ZQGDJ_' + CONVERT(VARCHAR(50), GETDATE(), 112) + '.bak' RESTORE DATABASE [DingHanECard_V2_ZQGDJ] FROM DISK = @name WITH REPLACE --只覆盖该日志的内容
其它详细内容可以 参考:使用SQL Server 2008维护计划实现数据库定时自动备份