Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I detached one sql 2012 DB and moved the file table folder and mdf and ldf files to another drive in the same machine. Now I need to attach the files
but got error
Please help

What I have tried:

I did the below steps
1. database -> right click ->attach
2.Clicked add button and selected the mdf file
3.clicked ok
It shows the below error
TITLE: Microsoft SQL Server Management Studio
------------------------------

Attach database failed for Server 'SQL7\MSSQLSERVER2012'.  (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.2218.0+((SQL11_RTM_GDR).120612-1251+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476


------------------------------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

------------------------------

Unable to open the physical file "D:\data\DB\MyFileTable". Operating system error 2: "2(The system cannot find the file specified.)".
A file activation error occurred. The physical file name 'D:\data\DB\MyFileTable' may be incorrect. Diagnose and correct additional errors, and retry the operation.
Could not open new database 'MYDB'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 5120)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=11.00.2218&EvtSrc=MSSQLServer&EvtID=5120&LinkId=20476


------------------------------
BUTTONS:

OK
------------------------------

D:\data\DB\MyFileTable was my previous path of the DB files. I now moved them to E drive.

This DB contains MDF , LDF files in the same path and along with that I have one folder to keep file table too in the same path. But previously the path was in D and the error message shows that it is still checking D drive for the file table.I moved the file table folder to D drive and MDF and LDF in E Drive itself and tried.Then it worked fine. But i need to move the file table also to E drive before attaching.
Posted
Updated 24-Oct-16 1:00am
v4
Comments
Member 10112611 24-Oct-16 6:59am    
This DB contains MDF , LDF files in the same path and along with that I have one folder to keep file table too in the same path. But previously the path was in D and the error message shows that it is still checking D drive for the file table.I moved the file table folder to D drive and MDF and LDF in E Drive itself and tried.Then it worked fine. But i need to move the file table also to E drive before attaching.

1 solution

Quote:
When you attach a database, all data files (MDF and LDF files) must be available. If any data file has a different path from when the database was first created or last attached, you must specify the current path of the file.
When you attach a database, if MDF and LDF files are located in different directories and one of the paths includes \\?\GlobalRoot, the operation will fail.

Attach a Database[^]
or just try copying file to its old location and try again.

Hope, it helps :)
 
Share this answer
 
Comments
Wendelius 22-Oct-16 4:30am    
Not copying all of the files could well cause this, a 5.
Member 10112611 23-Oct-16 0:36am    
Do we have option to specify path of file table while attaching? MDF and LDF path working fine but the problem is with filetable path

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900