Discussion Locked

SQL Server Restoration

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I need to restore a SQL server to a machine other than the origonal one. I have the .BAK file, but when I try do a restore I get various errors, such as "this database cannot be retored, try the WITH MOVE option" and others like that.

I have also been told that if I have the .mdf and .ldf files I can attach those to a DBand it works, bit I cant seem to find an option to attach files anywhere.

Please help!!!

Thanks
Gary Davis

3 replies

by awdfg

Hi Gary
If you have the mdf and ldf files then you can restore your databases by executing the following command in the Query Analyzer:

EXEC sp_attach_db @dbname = N'"db name"', @filename1 = N'"mdf filename"'
@filename2 = N'ldf filename"'

Give the name of the database in place of "db name".
Give the entire paths of the mdf and ldf files in place of "mdf filename" and "ldf filename".
Note that the single quotes are necessary.

Good Luck

This discussion is closed to new replies.