Database Backup Problems
1. If there is no database, create a database with the same name first, and then select backup. At this time, full backup is required, and component backup is not supported.
If both operations are normal and the system prompts "the database backup in the backup set is different from the existing one", run the statement.
Restore database workpointmanage_sassFROM DISK = 'C: \ Program Files \ Microsoft SQL Server \ MSSQL10_50.MSSQLSERVER \ MSSQL \ Backup \ done' -- 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. When the database is restored, the system prompts that the database is in use and the database needs to be detached before going online. If the manual operation is ineffective, the following statement is available:
Declare @ dbname varchar (20) set @ dbname = 'workpointmanage _ sass 'declare @ SQL nvarchar (500) declare @ spid int -- The SPID value is a unique Integer set @ SQL = 'descare getspid cursor forselect spid from sysprocesses where dbid = db_id (' ''' + @ dbname + ''') 'exec (@ SQL) open getspidfetch next from getspid into @ spidwhile @ fetch_status <>-1 -- if the FETCH statement does not fail to be executed or this row is not in the result set. Beginexec ('Kill '+ @ spid) -- terminate the normal connection fetch next from getspid into @ spidendclose getspiddeallocate getspid