SQL Server安装后,根据对应的业务场景,数据库实例的部分选项需要调整,例如实例的最大内存、tempdb 文件的增长量、Job执行记录数等等,但这一步经常被大家忽略掉。
其实很多选项初始化都可以通过脚本实现,一件执行。下面是一些常见选项初始的例子,仅供大家参考。
use master go --show advanced options sp_configure 'show advanced options',1 reconfigure with override PRINT show advanced options ok' GO Enable extend stored procedure xp_cmdshell sp_configure xp_cmdshellGo enabled xp_cmdshell okGO ------------------------------------------------------- ---------Configure how many memory server will used------------------------------------------------------------- declare @i as bigint select @i=ceiling(total_physical_memory_kb/10241024.0) From sys.dm_os_sys_memory if *0.2>20 begin set @i=(@i-10)*1024 set =201024 end else <4 4end else =0.8end Configure how many memory server will used exec sp_configure max server memory@i (该参数根据Sever内存大小具体决定) Reconfigure GO set max memory ok------------------------------------------------------- Set database Compress Backup EXEC sp_configure backup compression default1'; RECONFIGURE WITH OVERRIDE ---------配置代理错误日志文件------------------------------------------------------- exec msdb.dbo.sp_set_sqlagent_properties @jobhistory_max_rows50000,1)">@jobhistory_max_rows_per_job100 PRINT N配置代理错误日志文件 成功--------configure temp db's file growth ------------ ALTER DATABASE [tempdb] MODIFY FILE ( NAME = Ntempdev 100MB ) templog 100MB ) --Enable create ole auotmation (sp_oacreate)sp_configure 'Ole Automation Procedures',1reconfigure with overrideGOPRINT 'enabled sp_oacreate ok'--Enable distributed query/transaction in AD HOC query like opendatasource/operquerysp_configure 'Ad Hoc Distributed Queries',1)">GoPRINT 'enabled opendatasource/operquery ok'GO