删除数据库时提示数据库正在使用,无法删除问题
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博客 ” ,链接:https://blog.itpub.net/29634949/viewspace-1991316/
,如需转载,请注明出处,否则将追究法律责任。