copy of SQL Server 7 recovery method

Source: Internet
Author: User
Tags copy log sql
server| recovery in SQL Server 7 The tedious process of creating a new device to rebuild a database is canceled because MS has redesigned the way the database files are stored. New storage format, a database consisting of two files, MDF database files and LDF log files. So we can copy the two files of the database you want to back up when we reload the machine, and then restore it after reinstalling.

A stored procedure that provides this type of recovery in SQL Server.

1.sp_attach_db [@dbname =] dbname,[@filename1 =] Filename_n

Add a database to the system, specify the database name in dbname, filename_n the file and log files for the specified database. For example, I have a Voogiya library that stops SQL Server service backup VOOGIYA_DATA.MDF,VOOGIYA_LOG.LDF, starts SQL Server, deletes the library, and then copies the two files to the SQL Server data directory , execute the following statement in Query Analyzer:

EXEC sp_attach_db @dbname = Nvoogiya,
@filename1 = Nd:\mssql7\data\voogiya_data.mdf,
@filename2 = Nd:\mssql7\data\voogiya_log.ldf

Will add this library to SQL Server group.

2.sp_attach_single_file_db [@dbname =] dbname,
[@physname =] Physical_name

This command, like the one above, allows the log file SQL Server to be physical_name as long as the physical file name of the library is written on it. This stored procedure is run to execute the following stored procedures:

sp_detach_db @dbname = dbname

Also take the above example:

EXEC sp_detach_db @dbname = Voogiya
EXEC sp_attach_single_file_db @dbname = Voogiya,
@physname = D:\mssql7\data\voogiya_data.mdf

Be aware that users executing the above stored procedures are in the sysadmin.

The above method runs on Windows Nt 4.0,service pack5,sql Server 7.0.

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.