SQL Server 安装后部分选项初始化脚本

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

 

相关文章

本篇内容主要讲解“sqlalchemy的常用数据类型怎么使用”,感...
今天小编给大家分享一下sqlServer实现分页查询的方式有哪些的...
这篇文章主要介绍“sqlmap之osshell怎么使用”,在日常操作中...
本篇内容介绍了“SQL注入的知识点有哪些”的有关知识,在实际...
1. mssql权限sa权限:数据库操作,文件管理,命令执行,注册...
sql执行计划如何查看?在SPL庞大的数据中我们不知道如何查看...