还原数据库操作步骤
时间:2021-07-01 10:21:17
帮助过:37人阅读
MASTER
DECLARE @i INT
SELECT @i=1
DECLARE @sSPID VARCHAR(
100)
DECLARE KILL_CUR SCROLL
CURSOR FOR
SELECT SPID
FROM sysprocesses
WHERE DBID
=DB_ID(
‘你要KILL连接的数据库名字‘)
OPEN KILL_CUR
IF @@CURSOR_ROWS=0 GOTO END_KILL_CUR
FETCH FIRST
FROM KILL_CUR
INTO @sSPID
EXEC(
‘KILL ‘+@sSPID)
WHILE @i<@@CURSOR_ROWS
BEGIN
FETCH NEXT FROM KILL_CUR
INTO @sSPID
EXEC(
‘KILL ‘+@sSPID)
SELECT @i=@i+1
END
END_KILL_CUR:
CLOSE KILL_CUR
DEALLOCATE KILL_CUR
断开数据库连接后再点执行,即可还原成功。
还原数据库操作步骤
标签:sys 备份文件 技术 open 数据库连接 into .com eal sel