Link to home
Start Free TrialLog in
Avatar of zhshqzyc
zhshqzyc

asked on

Unable to open the physical file mdf, access denied

Hello,

I want to create a new database but failed.
My script:
USE master
GO
CREATE DATABASE [AdventureWorks2008] ON
( FILENAME = N'C:\SSIS\AdventureWorks2008R2_Data.mdf' )
FOR ATTACH
GO

Open in new window

The error message is:
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file "C:\SSIS\AdventureWorks2008R2_Data.mdf". Operating system error 5: "5(Access is denied.)".

Open in new window

SQL Server 2008 R2 Developer Edition.
Thanks for help.
ASKER CERTIFIED SOLUTION
Avatar of Rich Weissler
Rich Weissler

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zhshqzyc
zhshqzyc

ASKER

I don't know and I am not sure how to check the permission.
I would normally go to Windows Explorer, select the directory, right click and select 'properties'.  From there, select the "Security" tab.

If you don't have GUI access, you can use the commandline "icacls c:\ssis" and look thru there to see if the SQL Service account has permission.
(You MIGHT be able to do that from inside SQL with "exec xp_cmdshell 'icacls c:\ssis' ", but hopefully not... it should be locked down.

If you need help finding what permissions the service is running under, let me know.