我是这样备份的(backup database schoolmanage to disk 'c:\\schoolmanage' with INIT)
然后这样恢复的(restore database schoolmanage from disk='c:\\schoolmanage'
备份没有问题,但是恢复就出错.提示如下:'数据库正在使用,所以未能获得对数据库的排它性访问权'
请问怎样做这个恢复数据库?

解决方案 »

  1.   

    backup database schoolmanage to disk 'c:\\schoolmanage' with INIT
    use pubs --随便打开个其他库
    restore database schoolmanage from disk='c:\\schoolmanage'
      

  2.   

    如果是多用户环境的话 那没办法了 关闭所有连接 再restore
      

  3.   

    先kill掉所有的使用的用户邹老大有一个存储过程
    你可以找找简单思路就是declare cursor1 cursor for select spid from master..sysprocesses
    where spid > 50 --用户spidopen ---while @@fetch_status = 0
       begin 
         exec('kill ' + cast(@spid as varchar(20)))
         fetch next from cursor1 into @spid
       endcolse ..
    deallocate ..
    详细的你去找老大的程序
    ;)
      

  4.   

    1.建一个楼上的存储过程,建在Master中
    2.USE MASTER
      Exec KillSpid--存储过程
      Restore Database  XXX From Disk='XXX'