USE [master];
GO
RESTORE FILELISTONLY
FROM DISK = 'E:\SqlServer\最新数据库\GLASS_2024-03-02.bak' --查询bak备份信息
--关闭链接
ALTER DATABASE [GLASS]
SET OFFLINE WITH ROLLBACK IMMEDIATE
RESTORE DATABASE GLASS --还原到数据库
FROM DISK = 'E:\SqlServer\最新数据库\GLASS_2024-03-02.bak'
WITH replace, --替换
RECOVERY, --恢复
MOVE 'GLASS' TO 'E:\SqlServer\MSSQL16.SQLEXPRESS\MSSQL\DATA\GLASS.mdf', --设置新的数据库文件
MOVE 'GLASS_log' TO 'E:\SqlServer\MSSQL16.SQLEXPRESS\MSSQL\DATA\GLASS_log.ldf'; --设置新的日志文件
GO