Reputation: 35
I am trying to attach a database to my SQL Server 2016. I'm getting the following error - any advice?
Failed to retrieve data for this request.
(Microsoft.SqlServer.Management.Sdk.Sfc)ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
C:\TransportTest.bak is not a primary database file. (Microsoft SQL Server, Error: 5171)
Upvotes: 2
Views: 1656
Reputation: 28423
A backup(.bak) file is not supposed to be ATTACHED. It's a backup file (not .mdf file) that you have to RESTORE.
RESTORE DATABASE [TransportTest] FROM DISK ='C:\TransportTest.bak'
Also you can use try some alternative as mentioned here, in case of issue with .mdf files
Upvotes: 0
Reputation: 129
You should attach database file with .mdf extension.
SQL Server database has two operating system files: a data file and a log file. Data files contain data and objects such as tables, indexes, stored procedures, and views. Every database has one primary data file. The recommended file name extension for primary data files is .mdf
Upvotes: -1
Reputation: 551
You are trying to add a .bak file, .bak files need to be restored and not attached.
Upvotes: 2