T-SQL Tip: Retrieving SQL Server Instance-Related Information

The following T-SQL script returns the following instance-related information for a SQL Server installation:

--
--Returns SQL Server Instance-Related Information
--
SELECT
DEFAULT_DOMAIN() AS Domain,
SERVERPROPERTY('MachineName') AS ServerName,          
SUBSTRING(@@VERSION,0,CHARINDEX('-',@@version,0)) as SQLServerVersion,      
SERVERPROPERTY ('ProductLevel') AS ProductLevel,
SERVERPROPERTY ('Edition') AS Edition,        
SERVERPROPERTY('ServerName') AS Instance_Name

For more info, check out the following links:

  • SERVERPROPERTY 
  • @@VERSION 

  • Labels: ,