--查看內存使用狀況 SELECT * FROM sys.dm_os_performance_counters WHERE counter_name IN ('Target Server Memory (KB)','Total Server Memory (KB)') -- 設置最大內存 sp_configure 'show advanced options', 1 GO --sp_configure 'max server memory', 2147483647 --這是默認值 --RECONFIGURE --GO sp_configure 'max server memory', 100 --單位是M RECONFIGURE GO sp_configure 'show advanced options', 0 --立馬生效,能夠用來臨時釋放內存 --查看最大內存 SELECT cfg.name AS [Name], cfg.configuration_id AS [Number], cfg.minimum AS [Minimum], cfg.maximum AS [Maximum], cfg.is_dynamic AS [Dynamic], cfg.is_advanced AS [Advanced], cfg.value AS [ConfigValue], cfg.value_in_use AS [RunValue], cfg.description AS [Description] FROM sys.configurations AS cfg where description like'%memory%' --測試內存的增加 DECLARE @I INT SET @I=1 WHILE @I<=5 BEGIN INSERT INTO t_login_copy(username,name) select name,username from t_login_copy SET @I=@I+1 END