标签:
CREATE PROCEDURE KillSpid(@dbName varchar(20)) AS BEGIN DECLARE @sql nvarchar(500) DECLARE @spid int SET @sql=‘DECLARE getspid CURSOR FOR SELECT spid FROM sysprocesses WHERE dbid=db_id(‘‘‘+@dbName+‘‘‘)‘ EXEC (@sql) OPEN getspid FETCH next FROM getspid INTO @spid WHILE @@fetch_status<>-1 BEGIN EXEC(‘kill ‘+@spid) FETCH next FROM getspid INTO @spid END CLOSE getspid DEALLOCATE getspid END GO
恢复数据库:
关键字://Alter Database 被恢复的数据库名 Set Offline with Rollback immediate;
restore database 被恢复的数据库名 from disk = ‘备份文件路径‘;
//Alter Database 被恢复的数据库名 Set OnLine With rollback Immediate;
标签:
原文地址:http://www.cnblogs.com/shiningrise/p/3870506.html