Learning While Aging

MS SQL Server Express Error 5123 When Attaching a Database

I have been using MS SQL Server Management Studio Express to attach and detach my database for some time and have not had any problems until today. When I tried to attach a database, MS SQL Server Management Studio Express gave me error 5123:

Failed to retrieve data for this request. (Microsoft.SqlServer.Express.SmoEnum)

Additional Information:

CREATE FILE encountered operating system error 32(The process cannot access the file because it is being used by another process.) while attempting to open or create the physical file ‘C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\xxxx.mdf’. (Microsoft SQL Server, Error:5123)

I tried the following methods but none of them could fix the problem:

  • Close out Server Management Studio Express and re-launch it to attach the database
  • Close out Server Management Studio Express and Visual Studio 2005, then re-launch Server Management Studio Express to attach the database
  • Reboot my computer
  • Completely shut down my computer
  • Restart “SQL Server (SQLEXPRESS)” service
  • Login SQL Server Management Studio Express with sa account

After several hours of trial and error, I finally figured it out. I have both MS SQL Server 2000 and SQL Server 2005 Express installed on my computer, and somehow SQL Server 2000 is holding my database which causes the above error when SQL Server 2005 Express tries to attach the same database. So I stopped “MSSQLSERVER” service (for SQL Server 2000) and “MSSQLSERVER (SQLEXPRESS)” (for SQL Server 2005 Express), restarted “MSSQLSERVER (SQLEXPRESS)”, and then launched SQL Server Management Studio Express and successfully attached my database.

My questions are: how come I didn’t have this probem before? How come SQL Server 2000 can use a SQL Server 2005 database?

0 0 votes
Article Rating
Subscribe
Notify of
guest

10 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
DavydDavid
15 years ago

I would like to see the inscription “to be continied”:-D

Sandeep Kutwal
Sandeep Kutwal
12 years ago

 
Windows server 2008 EE 64bit was seems having problems in security applications on the folder and file.
 
Just copy intended mdb and related log file in newly create another folder.
 
Then try to attach same mdb , you will get it work!
 
 

Luis Enrique Rodríguez Paz
Luis Enrique Rodríguez Paz
11 years ago

Launch the SQL Server Management Studio with administrator privileges

Alex
Alex
11 years ago

1. copy the db file and log file to any other folder.
2. run th SSMS (SQL Server Management Studio) with "Run as administrator"
3. attach the db.
4. enjoy 🙂

vedant
vedant
11 years ago
Reply to  Alex

hello all,
 
1. copy the db file and log file to any other folder.
2. run th SSMS (SQL Server Management Studio) with "Run as administrator"
3. attach the db.
4. enjoy 🙂
       it's working for me,
 
  thanX guys
 

ksao
ksao
10 years ago
Reply to  vedant

hello all,
 
1. copy the db file and log file to any other folder.
2. run th SSMS (SQL Server Management Studio) with "Run as administrator"
3. attach the db.
4. enjoy 🙂
       it's working for me,

alireza
alireza
10 years ago
Reply to  vedant

thanks a lot

 

prabhu
prabhu
9 years ago

if all log and mdf file is live then i am not able copy…in this case what need to do.without stop live envoi….

atomsci
atomsci
9 years ago

open it on run as administrator

Hank
Hank
8 years ago

In SQL Server mostly the attach database error 5123 occurs at the time when you want to attach the database with the databases that are placed on different locations. Database roles also raise the error 5123, means that the detached database having different role and you are trying to attach the same with the different role. After a long research I found this helpful article here the error 5123 of attach database is described in simple words. http://sqltechtips.blogspot.com/2015/12/fix-attach-database-error-5123.html

10
0
Would love your thoughts, please comment.x
()
x