What version of SQL Server am I running?

Quite often I see the question in the SQL Server forums "What version of SQL Server am I running?"  To be honest, this is a VERY easy question to answer.  Microsoft provides a function with a set of properties you can query for identifying such information.  The function provided by Microsoft is SERVERPROPERTY.  However, there are specific parameters you need to pass to it to get the information you need.  So, rather than having to worry about these specific parameter values, I've created a system stored procedure that you can use to find out any information you need to about your SQL Server instance without having to know specific parameter values.  The code for the system stored procedure is below.

 

USE master
GO
CREATE PROCEDURE sp_ServerProperties
AS
SELECT
BuildClrVersion = SERVERPROPERTY('BuildClrVersion'),
Collation = SERVERPROPERTY('Collation'),
CollationID = SERVERPROPERTY('CollationID'),
ComparisonStyle = SERVERPROPERTY('ComparisonStyle'),
ComputerNamePhysicalNetBIOS = SERVERPROPERTY('ComputerNamePhysicalNetBIOS'),
Edition = SERVERPROPERTY('Edition'),
EditionID = SERVERPROPERTY('EditionID'),
EngineEdition = SERVERPROPERTY('EngineEdition'),
InstanceName = SERVERPROPERTY('InstanceName'),
IsClustered = SERVERPROPERTY('IsClustered'),
IsFullTextInstalled = SERVERPROPERTY('IsFullTextInstalled'),
IsIntegratedSecurityOnly = SERVERPROPERTY('IsIntegratedSecurityOnly'),
IsSingleUser = SERVERPROPERTY('IsSingleUser'),
LCID = SERVERPROPERTY('LCID'),
LicenseType = SERVERPROPERTY('LicenseType'),
MachineName = SERVERPROPERTY('MachineName'),
NumLicenses = SERVERPROPERTY('NumLicenses'),
ProcessID = SERVERPROPERTY('ProcessID'),
ProductVersion = SERVERPROPERTY('ProductVersion'),
ProductLevel = SERVERPROPERTY('ProductLevel'),
ResourceLastUpdateDateTime = SERVERPROPERTY('ResourceLastUpdateDateTime'),
ResourceVersion = SERVERPROPERTY('ResourceVersion'),
ServerName = SERVERPROPERTY('ServerName'),
SqlCharSet = SERVERPROPERTY('SqlCharSet'),
SqlCharSet = SERVERPROPERTY('SqlCharSetName'),
SqlSortOrder = SERVERPROPERTY('SqlSortOrder'),
SqlSortOrderName = SERVERPROPERTY('SqlSortOrderName'),
FilestreamShareName = SERVERPROPERTY('FilestreamShareName'),
FilestreamConfiguredLevel = SERVERPROPERTY('FilestreamConfiguredLevel'),
FilestreamEffectiveLevel = SERVERPROPERTY('FilestreamEffectiveLevel')

GO
use master
go
EXECUTE sp_ms_marksystemobject 'sp_ServerProperties'


Once you've created the procedure, you can execute it in the context of any database on your SQL Server instance to return all of the system properties for your SQL Server instance.  Note that this procedure is customized for SQL Server 2008.  The 2005 version will be absent a few of these properties...namely the FILESTREAM properties.

HTH,

Tim


Posted 11/1/2009 10:03 AM by TimChapman
Copyright SQL Server Nation 2010
Powered by Community Server (Non-Commercial Edition), by Telligent Systems