Determine the (available) amount of memory of a SQL Server (instance / machine)

Comming across a question of a colleague of mine, the following script can be used to determine the (available / assigned) amount of memory for an instance / machine. Notice that the DMVs are only available on SQL Server 2005, for using the script on versions 2000 and 2005 you will need to use the 2000 script. In addition be aware that one script uses internal sys tables which might change in the future of SQL Server (without notice) and you should better stick to the DMV if you want to keep your implementations futureproof.

SQL Server 2000:

Get the physical memory:

create table #SVer(ID int,  Name  sysname, Internal_Value int, Value nvarchar(512))
insert #SVer exec master.dbo.xp_msver
WHere Name = 'PhysicalMemory'

drop table #SVer                                              

Get the configured memory:

Select * FROM
sysconfigures AS cfg
Where comment IN
('Minimum size of server memory (MB)','Maximum size of server memory (MB)')


SQL Server 2005:

Get the physical memory:

from sys.dm_os_sys_info
getting the configured SQL Server options:

Get the configured memory:

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]
sys.configurations AS cfg
WHERE name IN ('min server memory (MB)','max server memory (MB)')


Skip to main content