Restore the copied SQL Server 7 Database

Source: Internet
Author: User
Restore the copied SQL Server 7 Database

In SQL Server 7, MS redesigned the storage mode of database files, removing the tedious process of creating a device and then creating a database. The new storage format. A database contains 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 reinstalling the machine, and then restore them.
SQL Server provides the restoration method for stored procedures.
1. sp_attach_db [@ dbname =] 'dbname', [@ filename1 =] 'filename _ n'
Add a database to the system, specify the database name in dbname, and specify the database file and log file in filename_n. For example, if I have a voogiya database, stop the SQL Server service from backing up voogiya_data.mdf, voogiya_log.ldf, start SQL server, and delete the database, then copy the two files to the SQL server DATA Directory and execute the following statement in Query Analyzer:
EXEC sp_attach_db @ dbname = n' voogiya ',
@ Filename1 = n'd: mssql7datavoogiya_data.mdf ',
@ Filename2 = n'd: mssql7datavoogiya_log.ldf'
The database will be added to the SQL Server Group.
2. sp_attach_single_file_db [@ dbname =] 'dbname ',
[@ Physname =] 'physical _ name'
This command is similar to the above function. In physical_name, you only need to write the physical file name of the database, and the SQL server of the log file will be re-created. To run this stored procedure, you must first execute the following stored procedure:
Sp_detach_db @ dbname = 'dbname'
Take the preceding example as an example:
EXEC sp_detach_db @ dbname = 'voogiya'
EXEC sp_attach_single_file_db @ dbname = 'voogiya ',
@ Physname = 'd: mssql7datavoogiya_data.mdf'
   

Note that the user executing the above stored procedure should be in sysadmin.

The preceding method runs on windows Nt 4.0, service pack5, and 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.