Thursday, December 9, 2010

Error When Trying to Attach an Existing Database

When trying to attach a SQL 2008 database today, I encountered this error:

CREATE FILE encountered operating system error 5 (error not found) while attempting to open or create the physical file 'D:\Databases\<filename>.mdf'. (.Net SqlClient Data Provider)

I’ve come across this issue every once in a while but somehow there’s this habit of forgetting the work around. So here, I post this bagger so I wouldn’t have to Google every time.

The error has something to do with SQL Server’s improved security for permissions.

Because I was logged in via SQL Server Authentication, it did not allow me to attach the database that way so that, I had to disconnect from the server and re-logon my Enterprise Manager thru Windows Authentication. Then, retried attaching my existing SQL database. And it worked!

No comments:

Post a Comment