首页 > 代码库 > 数据库删除

数据库删除

DECLARE @SPID VARCHAR(20)DECLARE #TB CURSOR FAST_FORWARD FORSELECT SPID=CAST(SPID AS VARCHAR(20)) FROM MASTER..SYSPROCESSES WHERE DBID=DB_ID(NTest)OPEN #TBFETCH NEXT FROM #TB INTO @SPIDWHILE @@FETCH_STATUS=0BEGIN     EXEC(KILL +@SPID)     FETCH NEXT FROM #TB INTO @SPIDENDCLOSE #TBDEALLOCATE #TBIF EXISTS(SELECT 1 FROM sys.databases WHERE name=NTest)DROP DATABASE MIES

 

数据库删除