January 3, 2017 at 2:21 pm
Hi All,
Someone gave me a .bak copy of the database. I tried to attach that database to my server and it keeps giving me an error saying "Db1.bak" is not a primary database file. I tried to change the extension of the database file to .mdf and then it gave me the same error saying C:\Databases\db1.mdf is not a primary database file(Microsoft sql server Error 5171).
I also tried to right click on the database and selected Restore database. I selected "Device" and pointed to my backup file and then I choose the Database name, but the OK button the bottom of the Restore database dialog does not get highlighted. I don't know how to do this sql server 2012.
Any help will be greatly appreciated.
January 3, 2017 at 2:30 pm
ATTACH is for an db1.MDF/db1.LDF pair of files.
what you need to do is RESTORE the database from a file.
http://www.mytechmantra.com/LearnSQLServer/How-to-Restore-Database-SQL-Server-P1.html
Lowell
January 3, 2017 at 9:42 pm
This was removed by the editor as SPAM
January 4, 2017 at 2:19 am
JasonClark (1/3/2017)
There are many symptoms which points in the direction of the error 5171.
However in this case it's because he tried to attach a backup instead of restoring it.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 4, 2017 at 3:45 am
anjaliagarwal5 (1/3/2017)
I also tried to right click on the database and selected Restore database. I selected "Device" and pointed to my backup file and then I choose the Database name, but the OK button the bottom of the Restore database dialog does not get highlighted.
Have you filled in any necessary fields on the other tabs, Files and Options?
January 4, 2017 at 6:02 am
All respect to the GUI, it's so much easier to backup and restore databases using T-SQL. Here's a good intro on the topic [/url]that ought to give you everything you need.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 5, 2017 at 6:15 am
Try T-SQL instead of GUI for restoring database.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply