gpt4 book ai didi

sql-server - 确保备份功能齐全

转载 作者:搜寻专家 更新时间:2023-10-30 20:16:53 25 4
gpt4 key购买 nike

这就是我计划备份数据库的方式。如何检查创建的备份是否功能齐全?

BACKUP DATABASE mytest TO DISK = 'C:\mytest.BAK'

最佳答案

检查 RESTORE VERIFYONLY -

BACKUP DATABASE [db] TO DISK = N'D:\BACKUP\db.bak'
GO
DECLARE @backupSetId AS INT
SELECT @backupSetId = position
FROM msdb.dbo.backupset
WHERE database_name = N'db'
AND backup_set_id = (
SELECT MAX(backup_set_id)
FROM msdb.dbo.backupset
WHERE database_name = N'db'
)
IF @backupSetId IS NOT NULL
BEGIN
RESTORE VERIFYONLY FROM DISK = N'D:\BACKUP\db.bak' WITH FILE = @backupSetId, NOUNLOAD, NOREWIND
END

关于sql-server - 确保备份功能齐全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34987324/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com