1

I had created a MDF database file and I just recently reformatted my computer. When I go to attach the database file to SQL Server, I get an "access is denied" error. I looked online and found that others have had a similar problem that was solved by running SQL server as administrator but that didn't work for me. I'm using Windows authenticate, if that helps to understand the problem.

I'm locked out!

Thanks.

frenchie
  • 51,731
  • 109
  • 304
  • 510
  • The SQL Server service account needs to have permissions on where the file is. Do you mean `mdf`? If not what is `dbf`? – Martin Smith Jan 11 '11 at 18:12
  • yes, it was a typo, it's a MDF file. Where's the functionality for SQL server permissions accessed from? How do I change it? – frenchie Jan 11 '11 at 18:19
  • You can find out what account it runs under by looking at the services in the services applet `Start -> Run -> Type services.msc -> Enter` then apply appropriate permissions on the mdf and ldf files (and/or their containing folder) to that account in Windows Explorer. – Martin Smith Jan 11 '11 at 18:51

2 Answers2

2

Add your user account to the System Administrator role. I suspect your account does not have the necessary permissions.

Abe Miessler
  • 82,532
  • 99
  • 305
  • 486
2

the service account- that SQL Server runs as-- must have permissions to get to the location where you have your MDF file.

for example, if you have your MDF file in the C:\SqlDatabases\ folder.. you need to make sure that the service account (the service that SQL Server runs as) has permissions to read and write to this directory.

Aaron Kempf
  • 580
  • 2
  • 11