How to recover data in SQL Server

Source: Internet
Author: User
Tags backup
server| Recovery | Several ways to recover data in SQL Server:

1. The nature is Backup recovery method Backup This is the safest and most reliable way to operate, as long as you select Restore in SQL Server's Enterprise Manager.

You can also do this with T-sql:

RESTORE DATABASE Test from DISK = ' C:\mssql7\backup\test.bak '

Of course, this is the use of the file recovery, if it is a device to restore nature is also possible.

2. But sometimes, SQL Server is in our unprepared situation paralyzed, sometimes accompanied by NT paralysis and caused, (this time, tofu want to Wall Gates portrait has still a few tomatoes), how to do? This is the time to adopt the system stored procedures provided in SQL Server's T-sql:

sp_atach_db

Here's a simple example:

sp_attach_db @dbname = N ' pubs ',

@filename1 = N ' C:\mssql7\data\pubs.mdf ',

@filename2 = N ' C:\mssql7\data\pubs_log.ldf '

This method should be said to have a high success rate, but in practice tofu heard this, the database becomes read-only, there is no way. If only MDF does not have LDF files, you can use the Sp_attach_single_file

sp_attach_single_file_db @dbname = ' pubs ', @physname = ' c:\mssql7\data\pubs.mdf '

This method would have been used to reverse the operation of the Sp_deatach, but the direct use would have been successful. Turn from: Dynamic Network production guide www.knowsky.com

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.