Categories
How-To Software Technical

Tech Short: TSQL to find Consumed Memory

Poking around in Microsoft SQL Server looking for a way to give me some statistics on memory usage, primarily consumed memory.

My first attempt was using ‘dbcc memorystatus’.  This gives me a good snapshot of the current memory status of the SQL Server. It will take me sometime to fully understand and parse the output.

So I kept looking for more details on how to show the consumed memory. And that is where I found the following query that gives me just what I am looking for.

 

Declare @MemTable Table
( row_id INT IDENTITY PRIMARY KEY, name VARCHAR(100), value BIGINT );
INSERT INTO @MemTable EXEC ( ‘DBCC MEMORYSTATUS’ );

SELECT top 1 Name,convert(decimal(16,2),value) / 1024/1024 ‘MBUsed’
FROM @MemTable
WHERE RTRIM(LTRIM(name)) = ‘Working Set’;

So if your looking for just the working set here you go

Thank you Jason Brimhall for the tip

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.