Convert Australian GDA94 Easting/Northing values to Latitude/Longitude in SQL Server

As I play around with the Cognos Analytics map controls, it appears to me it only understands Latitude/Longitude values, but the sample dataset I have is in UTM format. So, I have to find ways to convert Easting/Northing values to Lat/Long. Since I use SQL Server, attempting to create a column in "Geometry" data type from Easting/Northing value, then convert it to a "Geography" data type (Lat/Long) does not seem to work for me.

After some scrambling on the web, the below SQL Functions seem to work for me to convert Easting/Northing values (on the Australian GDA94, Zone 56 standard). The key to get it to work is setting the correct datum details in the constant section. A quick test of this function does seem to give me the correct Lat/Long coordinates of Sydney Habour Bridge:

A sample point from latlong.net



Testing the functions


The two pieces of T-SQL codes below are the same, the only difference is one returns Latitude, the other one returns Longitude value


1 comment:

  1. Hi Viet, as I am not a power user of SQL how do i use this?

    I have a table SERVICEADDRESS that contains the fileds SERVICEADDRESS.LATITUDEY and SERVICEADDRESS.LONGITUDEX
    which are in gda94 Easting and Northing

    ReplyDelete