Friday, July 6, 2012

Error: 5133 SQL Server while attaching the Database

Hi all,

One of my friend reported an error while trying to attached a database received from client to SQL SERVER 2008 R2.

The database received have only two files one is .mdf & second one is .ndf.

while attaching database to the server he was getting below error -

TITLE: Microsoft SQL Server Management Studio
Attach database failed for Server 'XXX-XX--XX'.  (Microsoft.SqlServer.Smo)

For help, click:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Directory lookup for the file "G:\SQLLOG\NAV_D_CQPA_370B_Log.ldf" failed with the operating system error 3(The system cannot find the path specified.). (Microsoft SQL Server, Error: 5133)

Resolution -

1) Check for the file path during attach.
In my case as i don't have the Log File (.ldf)  it was taking a random path which does not exist in the system.

2) Delete the selected file (in my case the log file) and click attach.

The system creates the missing file automatically.

Thanks & Regards,
Saurav Dhyani