用t-sql语句完整备份数据库的例子

发布时间:2019-10-06编辑:脚本学堂
本文介绍下,用t-sql语句,进行数据库完整备份的例子,有需要的朋友,参考下吧。

完整数据备份sql语句
 

复制代码 代码示例:

USE master;
--Create tail-log backup.
BACKUP LOG AdventureWorks
TO DISK = 'D:sql_backupstestdb.bak' WITH NORECOVERY;
GO
--Restore the full database backup (from backup set 1).
RESTORE DATABASE AdventureWorks
FROM DISK = 'D:sql_backupstestdb.bak'
WITH FILE=1,NORECOVERY;

--Restore the regular log backup (from backup set 2).
RESTORE LOG AdventureWorks
FROM DISK = 'D:sql_backupstestdb.bak'
WITH FILE=2,NORECOVERY;

--Restore the tail-log backup (from backup set 3).
RESTORE LOG AdventureWorks
FROM DISK = 'D:sql_backupstestdb.bak'
WITH FILE=3,NORECOVERY;
GO
--recover the database(finally)
RESTORE DATABASE AdventureWorks WITH RECOVERY;
GO