1

Topic: SQL Server Attach problem

I have just detached my NBNData database (to make a copy elsewhere), but on attempting to re-attach the database, I get the following error, HELP!:

TITLE: Microsoft SQL Server Management Studio
------------------------------

Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)

For help, click: http://go.microsoft.com/fwlink?ProdName … nkId=20476

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

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

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

CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file 'S:\DATA\NBNData_Data.MDF'. (Microsoft SQL Server, Error: 5123)

For help, click: http://go.microsoft.com/fwlink?ProdName … nkId=20476

Craig Slawson
Staffordshire Ecological Record

2 (edited by AndyFoy 21-10-2014 08:37:04)

Re: SQL Server Attach problem

It might be completely unrelated but I've seen a problem like this before where a database could be unattached without problems but could not be reattached.  It turned out that SQL Server Management Studio did not have sufficient permissions to the directory where the data files were stored.   It could obviously use the files and detached them but not attach them for some reason.

Andy Foy
Systems Manager
Greenspace Information for Greater London (GiGL) CIC
www.gigl.org.uk

3

Re: SQL Server Attach problem

Two possible solutions are:

1. Run SQL Server Management Studio as an administrator (if you are not already).
2. Give the SQL Server account full access to the .mdb and .ldf data and log files.

Andy Foy
Systems Manager
Greenspace Information for Greater London (GiGL) CIC
www.gigl.org.uk

4

Re: SQL Server Attach problem

A restart of the server failed to cure the problem, so I've had to restore from a backup, but I'm still assuming if I try to detach the database the above error will re-occur - any ideas which I can try to repair the database while I can actually access it?

Craig

Craig Slawson
Staffordshire Ecological Record

5 (edited by AndyFoy 21-10-2014 09:58:48)

Re: SQL Server Attach problem

Have you tried either of the above 2 solutions?  A Google search (other search engines are available) of 'Microsoft SQL Server Error 5123' comes up with lots of similar problems all of which point to permissions problems accessing the data/log files or creating/editing files in the folder.

Andy Foy
Systems Manager
Greenspace Information for Greater London (GiGL) CIC
www.gigl.org.uk

6

Re: SQL Server Attach problem

Andy,

Yes I did try both without success before I restored the database - after the restore I found Management Studio could backup the database, it was giving an error before, so I think it has sorted the problem, although I haven't dared to detach the database

Craig

Craig Slawson
Staffordshire Ecological Record