SQLVersion.func.sql 529 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
if object_id('PerformanceCollector.SQLVersion') is not null
drop function PerformanceCollector.SQLVersion
go

create function PerformanceCollector.SQLVersion ()
RETURNS VARCHAR(4)
as
begin
	declare @ver varchar(200)
	select @ver = convert(varchar(200),serverproperty('ProductVersion'))
	select @ver = left(@ver,2)
	--select @ver
	
	if @ver = '9.'
	begin
		SELECT @ver = '2005'
	end
	else if @ver = '10'
	begin
		SELECT @ver =  '2008'
	end
	else
	begin
		SELECT @ver =  'UNK'
	end
	
	RETURN @ver
end
go