DECLARE @SPID VARCHAR(20) DECLARE #TB CURSOR FAST_FORWARD FOR SELECT SPID=CAST(SPID AS VARCHAR(20)) FROM MASTER..SYSPROCESSES WHERE DBID=DB_ID(N‘Test‘) OPEN #TB FETCH NEXT FROM #TB INTO @SPID WHILE @@FETCH_STATUS=0 BEGIN EXEC(‘KILL ‘+@SPID) FETCH NEXT FROM #TB INTO @SPID END CLOSE #TB DEALLOCATE #TB IF EXISTS(SELECT 1 FROM sys.databases WHERE name=N‘Test‘) DROP DATABASE MIES
时间: 2024-11-06 09:33:49