microsoft sql server error 5123 attach database - how to fix

11
Fix SQL Server Error 5123 “CREATE FILE Encounter Operating System Error 5 (Access is denied).”

Upload: jasonclark03

Post on 20-Jan-2017

2.165 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Microsoft SQL Server Error 5123 Attach Database - How to Fix

  Fix SQL Server Error 5123

“CREATE FILE Encounter Operating System Error 5 (Access is denied).”

Page 2: Microsoft SQL Server Error 5123 Attach Database - How to Fix

Table of ContentsWhat is the Error 5123Reasons of the Error 5123How to Attach a Database

Attaching Database Using T-SQLUsing  sp_attach_db Stored Procedure

Methods to Fix the error 5123.ConclusionMore Resources

Page 3: Microsoft SQL Server Error 5123 Attach Database - How to Fix

What is the Error 5123?The error 5123 is a type of permission error in SQL Server database. The error 5123 occurs when you want to attach the database which are situated at different locations.

Screenshot of the prompted error 5123

Page 4: Microsoft SQL Server Error 5123 Attach Database - How to Fix

Reasons of the Error 5123

Attaching & detaching the with different logins.

Currently running process has no proper permission to run the program folder.

Page 5: Microsoft SQL Server Error 5123 Attach Database - How to Fix

How to Attach a Database

There are two methods to attach the database in SQL Server. Methods are as follows:

1. Attaching database Using T-SQL

2. Using sp_attach_db stored procedure

Page 6: Microsoft SQL Server Error 5123 Attach Database - How to Fix

Attaching Database Using T-SQL

CREATE DATABASE database_name ON (NAME = logical_file_name,FILENAME = 'os_file_name' ) [ ,..n ] AS SNAPSHOT OF source_database_name[;]

Page 7: Microsoft SQL Server Error 5123 Attach Database - How to Fix

Using sp_attach_db Stored Procedure

Using stored procedure, we can attach the databases in the SQL Server. Given below is syntax for attaching a database:

sp_attach_db [ @dbname= ] 'dbname’ , [ @filename1= ] 'filename_n' [ ,...16 ]

Page 8: Microsoft SQL Server Error 5123 Attach Database - How to Fix

Resolving the Issue 5123

You need to follow the given steps to fix the issue attach database failure in SQL Server:

1. Go to the .mdf file which you want to attach and right click on them.

2. Select the properties check the permissions of file.

Page 9: Microsoft SQL Server Error 5123 Attach Database - How to Fix

3. Click on the add button to grant the login permission and give the full login control to the mdf file and its associated ndf file also.

4. Now you can attach the file. It should work.

Continue

“You can try run as administrator rather than giving permission to everyone.”

Page 10: Microsoft SQL Server Error 5123 Attach Database - How to Fix

Conclusion

In this knowledge based tutorial I have shown that how can we attach the mdf / ldf files. If the attachment fails then what steps need to perform to overcome from this issue.

Page 11: Microsoft SQL Server Error 5123 Attach Database - How to Fix

More Resources

To know more about attach database error: 5123 in MS SQL Server you should go through this one.

http://sqltechtips.blogspot.in/2015/12/fix-attach-database-error-5123.html