“Comparing across multiple decimals”


declare @var1 varchar(20) = '11.8.800.94'
declare @var2 varchar(20) = '11.8.800.175'


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



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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s