用C#调用COM http://dev.csdn.net/develop/article/28/28564.shtm 不多说了
方法二:
1.备份数据库
backup database 被备份的数据库名 to disk ='备份文件路径';
2.恢复数据库
Alter Database 被恢复的数据库名 Set Offline with Rollback immediate;
restore database 被恢复的数据库名 from disk = '备份文件路径';
Alter Database 被恢复的数据库名 Set OnLine With rollback Immediate;
邹建的话:
--执行下面的语句强制断开数据库,再恢复就可以了
use master
declare tb cursor local for
select 'kill '+rtrim(spid) from sysprocesses where dbid=db_id('你的库名')
open tb
declare @s nvarchar(1000)
fetch tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch tb into @s
end
close tb
deallocate tb
declare tb cursor local for
select 'kill '+rtrim(spid) from sysprocesses where dbid=db_id('你的库名')
open tb
declare @s nvarchar(1000)
fetch tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch tb into @s
end
close tb
deallocate tb