Database Backup遇到的問題,Database Backup遇到

來源:互聯網
上載者:User

Database Backup遇到的問題,Database Backup遇到

1、沒有資料庫時先建立一個同名資料庫,然後選擇備份,此時需要全備份,分量備份不可以

     如果都正常操作還提示“備份組中的Database Backup與現有不同”則用語句執行

RESTORE DATABASE workpointmanage_sassFROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\workpointmanage_sass_datafull_201412040742_12040742.bak'   --bak檔案路徑with replace,MOVE 'workpointmanage_sass' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\workpointmanage_sass.mdf',   --mdf檔案路徑MOVE 'workpointmanage_sass_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\workpointmanage_sass.ldf'   --ldf檔案路徑

2、資料庫還原中提示資料庫正在被佔用,需要分離資料庫再聯機,手動操作無效時可用如下語句

    

declare @dbname varchar(20)set @dbname='workpointmanage_sass'declare @sql nvarchar(500)declare @spid int--SPID 值是當使用者進行串連時指派給該串連的一個唯一的整數set @sql='declare getspid cursor forselect spid from sysprocesses where dbid=db_id('''+@dbname+''')'exec (@sql)open getspidfetch next from getspid into @spidwhile @@fetch_status<>-1--如果FETCH 語句沒有執行失敗或此行不在結果集中。beginexec('kill '+@spid)--終止正常串連fetch next from getspid into @spidendclose getspiddeallocate getspid

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.