数据库常用配置选项

来源:互联网 发布:陕西广电网络客服电话 编辑:程序博客网 时间:2024/05/19 23:24
实例名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
原创粉丝点击