Skip to content

Instantly share code, notes, and snippets.

@spaghettidba
Created April 24, 2020 14:13
Show Gist options
  • Save spaghettidba/95c7c3c6339a9318943cb98922ec14a7 to your computer and use it in GitHub Desktop.
Save spaghettidba/95c7c3c6339a9318943cb98922ec14a7 to your computer and use it in GitHub Desktop.
sql version
DECLARE @ProductVersion varchar(15);
DECLARE @Edition varchar(15);
DECLARE @EngineEdition smallint;
DECLARE @HostPlatform varchar(15);
SELECT @ProductVersion = CAST(SERVERPROPERTY('ProductVersion') AS varchar(15)),
@Edition = CAST(SERVERPROPERTY('Edition') AS varchar(15)),
@EngineEdition = CAST(SERVERPROPERTY('EngineEdition') AS smallint)
DECLARE @Version int
SET @Version = LEFT(@ProductVersion, CHARINDEX('.', @ProductVersion) - 1)
IF @Version >= 14
BEGIN
SELECT @HostPlatform = host_platform
FROM sys.dm_os_host_info
END
ELSE
BEGIN
SET @HostPlatform = 'Windows'
END
SELECT @ProductVersion AS ProductVersion,
@Edition AS Edition,
@EngineEdition AS EngineEdition,
@HostPlatform AS HostPlatform
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment