alan murphy
alan murphy

Reputation: 11

How to attach a SQL database created under a different account

I created several SQL databases on an external drive using the local admin account on my PC. This PC was then recalled and rebuilt by Head Office. I have tried and failed to attach these databases to a new install of SSMS. All of this was done using SQL Server 2016 Developer Edition. I can created new DBS on the external drive. I have given my local admin account and the SQL NT Service account (including the SQL Agent one) full access to the folders, the .MDF and the .LDF files. The error is 'Create file encountered operating system error 5(access is denied.) while attempting to open or create the physical file 'D:|SQLDATA\TESTDB.mdf.' (Microsoft SQL Server, Error: 5123)

Could it be because I didn't detach the databases from the old SQL Server install, which no longer exists?

If anyone can help, I'll be very grateful.

Upvotes: 1

Views: 708

Answers (1)

Run Sql as administrator.

or

Right click on file. Propetries > Security.

change the security permissions of ldf , mdf file to full permissions.

Upvotes: 0

Related Questions