@liuruicai
2017-07-20T15:48:09.000000Z
字数 878
阅读 574
参考:Description of support for network database files in SQL Server
Microsoft SQL Server: How to attach database from network drive?
Attach a remotely stored database
CREATE DATABASE [DestinedForGreatness]
ON PRIMARY
( NAME = N'DestinedForGreatness', FILENAME = N'\\LittleBlackBox\SQL2012data\MSSQL\Data\DestinedForGreatness.mdf' )
LOG ON
( NAME = N'DestinedForGreatness_log', FILENAME = N'\\LittleBlackBox\SQL2012data\MSSQL\Data\DestinedForGreatness_log.ldf')
GO
–Turn On Allow Attach from Network Drive (UNC)
DBCC TraceOn(1807)
–Attach the database
EXEC sp_attach_db @dbname = N’DatabaseName’,
@filename1 = N’\\ServerName\SQL Data\DatabaseName_Data.MDF’,
@filename2 = N’\\ServerName\SQL Log\DatabaseName_Log.LDF’
–Turn Off Allow Attach from Network Drive (UNC)
DBCC TraceOff(1807)