开启参数优化
exec sp_configure 'show advanced options', 1 reconfigure;
exec sp_configure 'xp_cmdshell', 1 reconfigure;
exec sp_configure 'Ad Hoc Distributed Queries', 1 reconfigure;
exec sp_configure 'show advanced options', 0 reconfigure;
GO
/* 规则 如果16G及以下,给2G给操作系统 如果32G及以下,给4G给操作系统 如果32G以上(不含32G),给内存的10%给系统 */ use master go declare @physical_memory int declare @TempTable table ( [Index] VARCHAR(2000) , [Name] VARCHAR(2000) , [Internal_Value] VARCHAR(2000) , [Character_Value] VARCHAR(2000) ); INSERT INTO @TempTable EXEC xp_msver; SELECT @physical_memory=cast(Internal_Value as int) FROM @TempTable WHERE Name = 'PhysicalMemory'; print @physical_memory if @physical_memory<=1024*16 set @physical_memory=@physical_memory-1024*2 else if @physical_memory<=1024*32 set @physical_memory=@physical_memory-1024*4 else set @physical_memory=@physical_memory*0.9 print @physical_memory EXEC sys.sp_configure N'max server memory (MB)',@physical_memory GO RECONFIGURE WITH OVERRIDE GO