Database Backup Problems

Source: Internet
Author: User
Tags mssqlserver

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.