SQL数据库异常处理

EXEC sp_who2;

找到链接那个数据库的SPID

KILL <SPID>;

挨个全部KILL掉就好了

–sp_configure ‘show advanced options’, 1
–GO
–RECONFIGURE WITH OVERRIDE
–GO
sp_configure ‘allow updates’,1
GO
RECONFIGURE WITH OVERRIDE
GO
UPDATE sysdatabases SET status = 32768 WHERE dbid=DB_ID(‘THIS4_CS’)–dbid = db_id(N’THIS4_CS’)
GO
DBCC CHECKDB(‘THIS4_CS’)
GO
UPDATE sysdatabases SET status = 28 WHERE name = ‘THIS4_CS’–dbid = db_id(N’THIS4_CS’)
GO
sp_configure ‘allow updates’,0
GO
RECONFIGURE WITH OVERRIDE
GO
–sp_configure ‘show advanced options’, 0
–GO
–RECONFIGURE WITH OVERRIDE
–GO
–SELECT * FROM sysdatabases WHERE name LIKE ‘THIS4%’
alter database THIS4_CS set offline

EXEC sp_who2;
kill

发表评论

电子邮件地址不会被公开。 必填项已用*标注