解决办法:
使用以下语句查出占用model数据库的进程id,然后使用kill命令 杀掉进程
use master go declare @sql varchar(100) while 1=1 begin select top 1 @sql = 'kill '+cast(spid as varchar(3)) from master..sysprocesses where spid > 50 and spid <> @@spid and dbid = db_id('model') if @@rowcount = 0 break ; print(@sql) exec(@sql) end go
扩展:
查看model数据库被哪些进程占用了
use master go select spid from master.sys.sysprocesses where dbid = db_id('model');