HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Directory lookup failed when adding sample database to SQL Server 2012

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
directorysample2012sqladdingdatabasefailedwhenserverlookup

Problem

I am trying to add the AdventureWorks sample database to SQL Server 2012, but I get an error message:


Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "C:\Users\A\Documents\SQL Server Management Studio\Data\AdventureWorks2012_Data.mdf" failed with the operating system error 5(Access is denied.).

Solution

The error message seems pretty straightforward: Access is denied. You need to make sure the SQL Server service account has adequate permissions on C:\Users\A\Documents\SQL Server Management Studio\Data\, or better yet, move the MDF (and LDF, if it exists) to the default data/log folders for the instance (where this shouldn't be a problem, and which is a better home for your database files anyway).

You can find the default data/log folders by inspecting:

SELECT physical_name FROM sys.master_files;


Any of the paths presented here should be a valid location to use...

Code Snippets

SELECT physical_name FROM sys.master_files;

Context

StackExchange Database Administrators Q#20244, answer score: 3

Revisions (0)

No revisions yet.