MS SQL Error 5123 attaching a database file.

I had to reattach a Microsoft SQL 2005 database file for someone this morning. I’ve had to do it several times for this database as they are doing lots of testing for it and like to detach it, backup it up and reattach it.

This morning however, it wouldn’t let me reattach it. The management studio gave me an error 5123 trying to open or create the file. After some research it turns out to be a permissions problem.

I checked the permissions on the file and the person who had detached the file was the only one with access. So I granted Everyone full access and I was then able to reattach the database.

4 thoughts on “MS SQL Error 5123 attaching a database file.

  1. Hi, I ran into this today. I needed to re-attach a DB I had previously attached and dettached. For some reason when I wanted to re-attach it, it gave me this 5123 error. After checking for file locks (with handle.exe)and file permissions, I found that when I ran the SQL 2005 Management Studio with the right click > run as administrator option, I could then attach the database without a problem. I couldn’t re-create the problem though when I tried. Weird.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s