sa user unable to attach detach databases
With a new SQLServer install, if you selected ‘Mixed Mode’ authentication, chances are you want to be able to use your sa user to connect to the database. You will be able to connect just fine, but will soon discover that the sa user is limited in what it can do on your local machine. For instance, you will be unable to attach mdf files the way you are accustomed to. The reason is that, if you took all the defaults during your SQL Server installation, your sa account was defaulted to logon (to windows) as a service (a local service). This needs to be changed – the sa account needs to be able to logon as a Local account (specifically, a Local System account). The reason is that the System group, by default, has access to the entire filesystem on your machine.
SOLUTION
To change the way the sa account logs on to windows, you need to go into the Configuration Manager (not the SQL Server management studio). From the configuration manager, select your database server, right click its properties and then change it to log on as Local System.
Once, the sa account is able to logon as a local system account, it will be able to do all the things that require local filesystem access (such as attach, detach mdf files).
ALTERNATIVE SOLUTION
NOTE: If you do not want to change the sa account to logon as a Local System account, there is another option (a more tedious one). Since the sa account logs on as a Service, you will need to grant permissions to the Service group to every mdf file that you need to attach (Right click your mdf file, security and add the group called Service. This will also allow the sa user running under a Local Service account to access the mdf file.
Leave a Reply