How can I tell how much memory SQL Server is using
NEVER, EVER trust Task Manager to tell you how much memory SQL Server is using. Use the performance counter instead:
SELECT object_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Total Server Memory (KB)';
Tip: You can save that as a query shortcut in Tools > Options > Environment > Keyboard > Query Shortcuts.
You can also check for memory pressure (and whether you can do anything about it) using these queries:
SELECT object_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name IN ('Total Server Memory (KB)', 'Target Server Memory (KB)');
-- SQL Server 2012:
SELECT physical_memory_kb FROM sys.dm_os_sys_info;
-- Prior versions:
SELECT physical_memory_in_bytes FROM sys.dm_os_sys_info;
EXEC sp_configure 'max server memory';
For SQL 2008 R2 the memory query commands are as follows
SELECT object_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Total Server Memory (KB)';
SELECT object_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name IN ('Total Server Memory (KB)', 'Target Server Memory (KB)');
-- SQL Server 2012:
SELECT physical_memory_in_bytes FROM sys.dm_os_sys_info;
-- Prior versions:
SELECT physical_memory_in_bytes FROM sys.dm_os_sys_info;
Also note that the command
EXEC sp_configure 'max server memory';
may not work unless you have advanced options enabled. e.g. do this first
EXEC sp_configure 'show advanced options',1
RECONFIGURE
*(Credit to Aaron Bertrand for this information)*
Revised: 2017-02-01
Copied!