3

Is it possible to attach a database that is stored on a remote server because when I mapped a drive and tried to attach it in management studio, the drive does not show up as an option. I moved it because of disk space and if I cannot what is the alternative suggestions?

4

1 回答 1

3

You should be able to attach a database on UNC path (I wouldn't use a mapped drive - that drive is mapped for you, not the SQL Server service account), but you have to ensure that the SQL Server service account has read/write permissions on the remote folder, and you have to run trace flag 1807 (please read Brent Ozar's post about this).

Also don't use the GUI for this. Once you have the trace flag set, have restarted the service, and have configured permissions correctly, use a new query window, and run the following command:

CREATE DATABASE db_name 
ON (Filename = '\\uncpath\share\file.mdf'),
   (Filename = '\\uncpath\share\file.ldf')
FOR ATTACH;

(The UI is never going to offer you a UNC path no matter what trace flags you have set or what permissions are enabled.)

Be prepared to handle a corrupted and possibly unrecoverable database should the network share go down, of course.

If that sounds scary to you, good! It should! This is not a good idea at all. Instead you should free up some space, add a drive, or host the database on a different instance.

于 2013-03-30T20:09:37.160 回答