Tuesday, May 8, 2012

Could not find property or field 'LAT' for type 'Microsoft.SqlServer.Types.SqlGeography'

PROBLEM:
You are trying to query geography data type
SELECT GEOLOCATION.LAT, GEOLOCATION.LONG FROM GEOLOCATION_TABLE
or
select geolocation.lat, geolocation.long from geolocation_table
and gets the following error:
Could not find property or field 'LAT' for type 'Microsoft.SqlServer.Types.SqlGeography'
or
Could not find property or field 'lat' for type 'Microsoft.SqlServer.Types.SqlGeography'

SOLUTION:
CLR types  are case sensitive by default. You should use "Lat" and "Long"
SELECT GEOLOCATION.Lat, GEOLOCATION.Long FROM GEOLOCATION_TABLE;

If you find this solution useful, you are welcome to press one of the ads in this page.. Thanks!

1 comment: