“Comparing across multiple decimals”


http://social.msdn.microsoft.com/Forums/sqlserver/en-US/0d366850-c0e3-43c9-9d45-b4c9380aefc5/comparing-across-multiple-decimals?forum=transactsql

declare @var1 varchar(20) = '11.8.800.94'
declare @var2 varchar(20) = '11.8.800.175'
select
--parsename(@var1,4),
--parsename(@var1,3),
--parsename(@var1,2),
--parsename(@var1,1),

--parsename(@var2,4),
--parsename(@var2,3),
--parsename(@var2,2),
--parsename(@var2,1)

CASE WHEN parsename(@var1,4)>=parsename(@var2,4)
Then CASE WHEN parsename(@var1,3)>=parsename(@var2,3)
THEN CASE WHEN parsename(@var1,2)>=parsename(@var2,2)
Then CASE WHEN parsename(@var1,1)>=parsename(@var2,1)
Then 'earlier version5'
Else 'earlier version4' End
Else 'earlier version3' End
Else 'earlier version2' End
Else 'earlier version1'
End as test

 

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