1, there is no database to create a database with the same name, and then select the backup, at this time full backup required, component backup can not
If both normal operation also prompts " database backup in Backup set is different from existing ", execute with statement
RESTORE DATABASE workpointmanage_sassfrom DISK = ' C:\Program Files\Microsoft SQL Server\mssql10_50.mssqlserver\mssql\ Backup\workpointmanage_sass_datafull_201412040742_12040742.bak ' --bak file path with Replace,move ' Workpointmanage_ Sass ' to ' C:\Program Files\Microsoft SQL Server\mssql10_50.mssqlserver\mssql\data\workpointmanage_sass.mdf ', -- MDF file path move ' workpointmanage_sass_log ' to ' C:\Program Files\Microsoft SQL Server\mssql10_50.mssqlserver\mssql\data\ Workpointmanage_sass.ldf ' --ldf file path
2, database restore prompts the database is occupied, need to separate the database and online, the manual operation is invalid when the following statements can be used
DECLARE @dbname varchar Set @dbname = ' workpointmanage_sass ' declare @sql nvarchar declare @spid int--spid The value is a unique integer set that is assigned to the connection when the user connects @sql = ' Declare getspid cursor forselect spid from sysprocesses where dbid=db_id ("' [email protected]+ ') ' EXEC (@sql) Open Getspidfetch next from getspid to @spidwhile @ @fetch_status <>-1--if fetch The statement did not fail to execute or the row is not in the result set. Beginexec (' kill ' [email protected])--Terminate normal connection fetch next from getspid to @spidendclose getspiddeallocate getspid
Problems with Database backup