在附加多个.MDF文件时重新建立日志
2010-06-21 00:00:00 来源:WEB开发网注意:我使用xp_cmdshell来删除.ldf文件。如果你没有激活xp_cmdshell,那么你会得到下面的错误。
错误:
Msg 15281, Level 16, State 1, Procedure xp_cmdshell, Line 1
SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell'
because this component is turned off as part of the security configuration for this server.
A system administrator can enable the use of 'xp_cmdshell' by using sp_configure. For more
information about enabling 'xp_cmdshell', see "Surface Area Configuration" in SQL Server Books Online.
你可以使用下面的事务SQL语句来激活xp_cmdshell 。
use master
go
sp_configure 'show advanced options',1
go
reconfigure with override
go
sp_configure 'xp_cmdshell',1
go
reconfigure with override
go
或者,你可以在MS-DOS命令提示符中使用Windows Explorer的“Del”命令来删除.ldf文件。
现在,让我们使用sp_attach_db试着只附加.MDF文件。执行下面的命令。
sp_attach_db 'MyDB1','C:\Data\MyDB1.mdf',
'C:\Data\MyDB2.mdf','C:\Data\MyDB3.mdf',
'C:\Data\MyDB4.mdf','C:\Data\MyDB5.mdf',
'C:\Data\MyDB6.mdf','C:\Data\MyDB7.mdf',
'C:\Data\MyDB8.mdf','C:\Data\MyDB9.mdf',
'C:\Data\MyDB10.mdf','C:\Data\MyDB11.mdf',
'C:\Data\MyDB12.mdf','C:\Data\MyDB13.mdf',
'C:\Data\MyDB14.mdf','C:\Data\MyDB15.mdf',
'C:\Data\MyDB16.mdf','C:\Data\MyDB17.mdf',
更多精彩
赞助商链接