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:mssql7ackup est.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? At this time, only SQL Server-T The system stored procedures provided in:
Here's a simple example:
sp_attach_db @dbname = N ' pubs ',
@filename1 = N ' C:mssql7datapubs.mdf ',
@filename2 = N ' C:mssql7datapubs_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:mssql7datapubs.mdf '
This method would have been used to reverse the operation of the Sp_deatach, but the direct use would have been successful.