標籤:
1.
“訊息 15281,層級 16,狀態 1,過程 xp_cmdshell,第 1 行
SQL Server 阻止了對組件 ‘xp_cmdshell‘ 的 過程‘sys.xp_cmdshell‘ 的訪問,因為此組件已作為此伺服器安全配置的一部分而被關閉。系統管理員可以通過使用 sp_configure 啟用 ‘xp_cmdshell‘。有關啟用 ‘xp_cmdshell‘ 的詳細資料,請參閱 SQL Server 聯機叢書中的 "介面區配置器". ”
解決方案:
sqlserver2005時
EXEC sp_configure N‘show advanced options‘, N‘1‘
RECONFIGURE WITH OVERRIDE
EXEC sp_configure N‘xp_cmdshell‘, N‘1‘
RECONFIGURE WITH OVERRIDE
EXEC sp_configure N‘show advanced options‘, N‘0‘
RECONFIGURE WITH OVERRIDE
如果不是sqlserver2005可使用如下的方法(我沒有實驗)
EXEC sp_configure ‘show advanced options‘, 1;RECONFIGURE;EXEC sp_configure ‘xp_cmdshell‘, 1;RECONFIGURE
RECONFIGURE:指定如果配置設定不需要伺服器停止並重新啟動,則更新當前啟動並執行值,如果沒有這個關鍵字的話將要重新啟動sqlserver服務才會生效。
Remind:開啟執行順序是‘show advanced options‘,然後才執行‘xp_cmdshell‘。,如果要關閉這個進階選項的話,要先執行‘xp_cmdshell‘然後再執行‘show advanced options‘。數字1代表開啟,0代表關閉。
如果cmdshell還不行的話,就再運行:
dbcc addextendedproc("xp_cmdshell","xplog70.dll");--
或者
sp_addextendedproc xp_cmdshell,@dllname=‘xplog70.dll‘
來恢複cmdshell。
2.
執行 master.dbo.xp_cmdshell ‘osql -U sa -P 123456 -i d:\test.sql‘
開啟較大儲存量的.sql檔案時,出現SQL Server 阻止了對組件 'xp_cmdshell' 的 過程'sys.xp_cmdshell' 的訪問