backup database titipwsd to disk='D:\\SysBackup\\Sys.bak' with init  --加上这个就不会出现每次备份 sys.bak就大一点

解决方案 »

  1.   

    恢复的时候出错,是因为要恢复的数据库正在使用,你要断开所有用户的连接,包括自己的连接才能恢复(你自己先断开连接,重新连接到master数据库,再进行恢复)
      

  2.   

    /*
    断开所有用户打开的连接
    */
    use master
    goif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[p_killspid]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
    drop procedure [dbo].[p_killspid]
    GOcreate proc p_killspid
    @dbname varchar(200) --要关闭进程的数据库名
    as  
    declare @sql  nvarchar(500)  
    declare @spid nvarchar(20) declare #tb cursor for
    select spid=cast(spid as varchar(20)) from master..sysprocesses where dbid=db_id(@dbname)
    open #tb
    fetch next from #tb into @spid
    while @@fetch_status=0
    begin  
    exec('kill '+@spid)
    fetch next from #tb into @spid
    end  
    close #tb
    deallocate #tb
    go--用法  
    exec p_killspid  '数据库名'
      

  3.   

    back database to with int,nounload,name=n"xx.bak",skip,format(noformat)