Contact Us

Use the form on the right to contact us.

You can edit the text in this area, and change where the contact form on the right submits to, by entering edit mode using the modes on the bottom right. 


Oak Ridge, TN, 37830
United States

Sql-Sangria

Count Decimal Places

Wade Cantley

The Decimal Splash

  • 1 1/2 oz. TY KU Liqueur
  • 1 oz. apple juice
  • Splash of sugar-free cranberry juice

I needed a way to see if a Latitude and Longitude value was long enough to be precise.  To be precise it needs to be at least 6 decimal places long so I needed to count the decimals.  

Here is what I found.

select latitude, longitude
from TableWithGeoLocations
where 

LEN(CAST(REVERSE(SUBSTRING(STR(latitude, 13, 11), CHARINDEX('.', STR(latitude, 13, 11)) + 1, 20)) AS decimal)) <= 6
or 
LEN(CAST(REVERSE(SUBSTRING(STR(longitude, 13, 11), CHARINDEX('.', STR(longitude, 13, 11)) + 1, 20)) AS decimal)) <= 6

This worked great to filter out the records that needed better geolocation data.