數據庫常用配置選項

實例名Database Enginexp_cmdshell—> 
  啓用 
  2.sp_configure 
  -- 允許配置高級選項 
  EXEC sp_configure 'show advanced options', 1 
  GO 
  -- 重新配置 
  RECONFIGURE 
  GO 
  -- 啓用xp_cmdshell 
  EXEC sp_configure 'xp_cmdshell', 0 
  GO 
  --重新配置 
  RECONFIGURE 
  GO 
  --執行想要的xp_cmdshell語句 
  Exec xp_cmdshell 'query user' 
  GO 
  --用完後,要記得將xp_cmdshell禁用(從安全角度安全考慮) 
  -- 允許配置高級選項 
  EXEC sp_configure 'show advanced options', 1 
  GO 
  -- 重新配置 
  RECONFIGURE 
  GO 
  -- 禁用xp_cmdshell 
  EXEC sp_configure 'xp_cmdshell', 1 
  GO 
  --重新配置 
  RECONFIGURE 
  GO

使用 sp_configure 時,必須在設置一個配置選項後運行 RECONFIGURE 或者 RECONFIGURE WITH OVERRIDE。RECONFIGURE WITH OVERRIDE 語句通常專門用來設置那些使用起來應當十分小心的配置選項。但是,RECONFIGURE WITH OVERRIDE 可用於所有的配置選項,並且可以用它代替 RECONFIGURE。
每個選項的值都可使用以下語句確定。
SELECT * FROM sys.configurations
ORDER BY name ;
GO


若要用 sp_configure 配置高級選項,必須首先在 "show advanced options" 選項設置爲 1 的情況下運行 sp_configure,然後運行 RECONFIGURE:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'cursor threshold', 0;
GO
RECONFIGURE;
GO

exec sp_configure 'show advanced options',1
go
reconfigure;
go
exec sp_configure 'Ad Hoc Distributed Queries',1
go
reconfigure;
go
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章