用restore database 数据库 from disk=N'" & 文件名 & "'" 用什么语句叛断要恢复

select count(spid) from sysprocesses where dbid=db_id(数据库)

如果>0,表示正在有人用。

其中:db_id 是SQL Server的函数,返回值是数据库的 id ,dbid 和 spid 是 sysprocesses 的两个列,spid 是进程号。

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus