Msg 3702:Cannot drop the database 'gcard' because it is currently in use.

dayong2015發表於2016-02-19
刪除資料庫時提示資料庫正在使用,無法刪除問題
1> select db_name()
2> go

 ------------------------------------------------------------
 master

(1 row affected)
1> drop database gcard
2> go
Msg 3702, Level 16, State 4:
Server 'SYBASE', Line 1:
Cannot drop the database 'gcard' because it is currently in use.
1>
1> alter database gcard set single_user with rollback immediate
2> go
Msg 156, Level 15, State 2:
Server 'SYBASE', Line 1:
Incorrect syntax near the keyword 'with'.
1>

解決辦法:
1、使用sp_who檢視與所要刪除資料庫的相關程式資訊
1> sp_who
2> go
 fid    spid     status               loginame         origname         hostname         blk_spid         dbname       tempdbname           cmd                                block_xloid            threadpool
 ------ -------- -------------------- ---------------- ---------------- ---------------- ---------------- ------------ -------------------- ---------------------------------- ---------------------- --------------------------------
 
   0      11     background           NULL             NULL             NULL                    0         gcard        tempdb               REP AGENT                                    0            NULL  

(12 rows affected)
(return status = 0)
1>
2、kill掉相關程式
1> kill 11 with force
2> go
1> sp_who
2> go
3、刪庫
1> drop database gcard
2> go
-------------END-----------

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29634949/viewspace-1991316/,如需轉載,請註明出處,否則將追究法律責任。

相關文章