T-SQL – Checking SQL Server Version and Service Packs

T-SQL – Checking SQL Server Version and Service Packs

Often, you will need to check for SQL Server versions and service packs. Some of the features that you are using are only available from a service pack onward.

Microsoft provides the function serverproperty to query for that kind of information.

SELECT
CAST(SERVERPROPERTY(‘ComputerNamePhysicalNetBIOS’)
AS VARCHAR(17)) AS ‘Computer physical name’,


CAST(SERVERPROPERTY(‘ServerName’)
AS VARCHAR(17)) AS ‘Server name’,


CAST(SERVERPROPERTY(‘MachineName’)
AS VARCHAR(17)) AS ‘Machine name’,


CAST(SERVERPROPERTY(‘Edition’)
AS
VARCHAR(25)) AS ‘Server edition’,


CAST(SERVERPROPERTY(‘InstanceName’)
AS VARCHAR(17)) AS ‘Instance name’,


CAST(SERVERPROPERTY(‘LicenseType’)
AS VARCHAR(15)) AS ‘License type’,


CAST(SERVERPROPERTY(‘ProductVersion’)
AS VARCHAR(15)) AS ‘Version’,


CAST(SERVERPROPERTY(‘ProductLevel’)
AS VARCHAR(15)) AS ‘Service pack’;

Go

 

for more information like CPU, Ram and etc. you can use below script:

 

SELECT SERVERPROPERTY(‘ServerName’) AS [SQLServer],
–@@microsoftversion/0x01000000 AS [MajorVersion],
SERVERPROPERTY(‘ProductVersion’) AS [VersionBuild],
SERVERPROPERTY(‘ProductLevel’) AS [Product],
SERVERPROPERTY (‘Edition’) AS [Edition],
–SERVERPROPERTY(‘IsIntegratedSecurityOnly’) AS [IsWindowsAuthOnly],
–SERVERPROPERTY(‘IsClustered’) AS [IsClustered],
[cpu_count] AS [CPUs],
[physical_memory_in_bytes]/1048576 AS [RAM (MB)]
FROM [sys].[dm_os_sys_info]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s