Unable to attach new database

Viewed 405

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)

3 Answers

You are trying to add a .bak file, .bak files need to be restored and not attached.

enter image description here

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

Related