I've converted a Javascript implementation into T-SQL functions for the WGS84 to Latitude/Longitude values. Feel free to use as you see fit. If you need a different coordinate system, check out the University of Wisconsin - Green Bay web page that I used as a source and get the updated constants.
drop function UF_utm_to_lat
go
create function UF_utm_to_lat(@utmz float, @x float, @y float) returns float
as
begin
--Based on code from this page: http://www.uwgb.edu/dutchs/usefuldata/ConvertUTMNoOZ.HTM
declare @latitude float;
declare @longitude float;
set @latitude = 0.00;
set @longitude = 0.00;
--Declarations
declare @a float;
declare @f float;
declare @drad float;
declare @k0 float;
declare @b float;
declare @e float;
declare @e0 float;
declare @esq float;
declare @e0sq float;
declare @zcm float;
declare @e1 float;
declare @M float;
declare @mu float;
declare @phi1 float;
declare @C1 float;
declare @T1 float;
declare @N1 float;
declare @R1 float;
declare @D float;
declare @phi float;
declare @lng float;
declare @lngd float;
--Datum Info here: Name, a, b, f, 1/f
--WGS 84 6,378,137.0 6356752.314 0.003352811 298.2572236
set @a = 6378137.0;
set @b = 6356752.314;
set @f = 0.003352811;
set @drad = PI()/180.0;
set @k0 = 0.9996; --scale on central meridian
set @e = SQRT(1.0 - (@b/@a)*(@b/@a)); --Eccentricity
--e = Math.sqrt(1 - (b/a)*(b/a));//eccentricity
set @e0 = @e/SQRT(1.0 - @e*@e); --Called e prime in reference
--e0 = e/Math.sqrt(1 - e*e);//Called e prime in reference
set @esq = (1.0 - (@b/@a)*(@b/@a)); --e squared for use in expansions
--esq = (1 - (b/a)*(b/a));//e squared for use in expansions
set @e0sq = @e*@e/(1.0-@e*@e); --e0 squared - always even powers
--e0sq = e*e/(1-e*e);// e0 squared - always even powers
set @zcm = 3.0 + 6.0*(@utmz-1.0) - 180.0; --Central meridian of zone
--zcm = 3 + 6*(utmz-1) - 180;//Central meridian of zone
set @e1 = (1.0 - SQRT(1.0 - @e*@e))/(1.0 + SQRT(1.0 - @e*@e)); --Called e1 in USGS PP 1395 also
--e1 = (1 - Math.sqrt(1 - e*e))/(1 + Math.sqrt(1 - e*e));//Called e1 in USGS PP 1395 also
set @M = 0.0 + @y / @k0; --Arc length along standard meridian
--M = M0 + y/k0;//Arc length along standard meridian.
set @mu = @M/(@a*(1.0 - @esq*(1.0/4.0 + @esq*(3.0/64.0 + 5.0*@esq/256.0))));
--mu = M/(a*(1 - esq*(1/4 + esq*(3/64 + 5*esq/256))));
set @phi1 = @mu + @e1*(3.0/2.0 - 27.0*@e1*@e1/32.0)*SIN(2.0*@mu) + @e1*@e1*(21.0/16.0 - 55.0*@e1*@e1/32.0)*SIN(4.0*@mu); --Footprint Latitude
--phi1 = mu + e1*(3/2 - 27*e1*e1/32)*Math.sin(2*mu) + e1*e1*(21/16 -55*e1*e1/32)*Math.sin(4*mu);//Footprint Latitude
set @phi1 = @phi1 + @e1*@e1*@e1*(SIN(6.0*@mu)*151.0/96.0 + @e1*SIN(8.0*@mu)*1097.0/512.0);
--phi1 = phi1 + e1*e1*e1*(Math.sin(6*mu)*151/96 + e1*Math.sin(8*mu)*1097/512);
set @C1 = @e0sq*POWER(COS(@phi1),2.0);
--C1 = e0sq*Math.pow(Math.cos(phi1),2);
set @T1 = POWER(TAN(@phi1),2.0);
--T1 = Math.pow(Math.tan(phi1),2);
set @N1 = @a/SQRT(1.0-POWER(@e*SIN(@phi1),2.0));
--N1 = a/Math.sqrt(1-Math.pow(e*Math.sin(phi1),2));
set @R1 = @N1*(1.0-@e*@e)/(1.0-POWER(@e*SIN(@phi1),2.0));
--R1 = N1*(1-e*e)/(1-Math.pow(e*Math.sin(phi1),2));
set @D = (@x-500000.0)/(@N1*@k0);
--D = (x-500000)/(N1*k0);
set @phi = (@D*@D)*(1.0/2.0 - @D*@D*(5.0 + 3.0*@T1 + 10.0*@C1 - 4.0*@C1*@C1 - 9.0*@e0sq)/24.0);
--phi = (D*D)*(1/2 - D*D*(5 + 3*T1 + 10*C1 - 4*C1*C1 - 9*e0sq)/24);
set @phi = @phi + POWER(@D,6.0)*(61.0 + 90.0*@T1 + 298.0*@C1 + 45.0*@T1*@T1 - 252.0*@e0sq - 3.0*@C1*@C1)/720.0;
--phi = phi + Math.pow(D,6)*(61 + 90*T1 + 298*C1 + 45*T1*T1 -252*e0sq - 3*C1*C1)/720;
set @phi = @phi1 - (@N1*TAN(@phi1)/@R1)*@phi;
--phi = phi1 - (N1*Math.tan(phi1)/R1)*phi;
set @latitude = FLOOR(1000000.0*@phi/@drad)/1000000.0;
set @lng = @D*(1.0 + @D*@D*((-1.0 - 2.0*@T1 - @C1)/6.0 + @D*@D*(5.0 - 2.0*@C1 + 28.0*@T1 - 3.0*@C1*@C1 + 8.0*@e0sq + 24.0*@T1*@T1)/120))/COS(@phi1);
set @lngd = @zcm+@lng/@drad;
set @longitude = FLOOR(1000000.0*@lngd)/1000000.0;
return @latitude;
end
go
drop function UF_utm_to_long
go
create function UF_utm_to_long(@utmz float, @x float, @y float) returns float
as
begin
--Based on code from this page: http://www.uwgb.edu/dutchs/usefuldata/ConvertUTMNoOZ.HTM
declare @latitude float;
declare @longitude float;
set @latitude = 0.00;
set @longitude = 0.00;
--Declarations
declare @a float;
declare @f float;
declare @drad float;
declare @k0 float;
declare @b float;
declare @e float;
declare @e0 float;
declare @esq float;
declare @e0sq float;
declare @zcm float;
declare @e1 float;
declare @M float;
declare @mu float;
declare @phi1 float;
declare @C1 float;
declare @T1 float;
declare @N1 float;
declare @R1 float;
declare @D float;
declare @phi float;
declare @lng float;
declare @lngd float;
--Datum Info here: Name, a, b, f, 1/f
--WGS 84 6,378,137.0 6356752.314 0.003352811 298.2572236
set @a = 6378137.0;
set @b = 6356752.314;
set @f = 0.003352811;
set @drad = PI()/180.0;
set @k0 = 0.9996; --scale on central meridian
set @e = SQRT(1.0 - (@b/@a)*(@b/@a)); --Eccentricity
--e = Math.sqrt(1 - (b/a)*(b/a));//eccentricity
set @e0 = @e/SQRT(1.0 - @e*@e); --Called e prime in reference
--e0 = e/Math.sqrt(1 - e*e);//Called e prime in reference
set @esq = (1.0 - (@b/@a)*(@b/@a)); --e squared for use in expansions
--esq = (1 - (b/a)*(b/a));//e squared for use in expansions
set @e0sq = @e*@e/(1.0-@e*@e); --e0 squared - always even powers
--e0sq = e*e/(1-e*e);// e0 squared - always even powers
set @zcm = 3.0 + 6.0*(@utmz-1.0) - 180.0; --Central meridian of zone
--zcm = 3 + 6*(utmz-1) - 180;//Central meridian of zone
set @e1 = (1.0 - SQRT(1.0 - @e*@e))/(1.0 + SQRT(1.0 - @e*@e)); --Called e1 in USGS PP 1395 also
--e1 = (1 - Math.sqrt(1 - e*e))/(1 + Math.sqrt(1 - e*e));//Called e1 in USGS PP 1395 also
set @M = 0.0 + @y / @k0; --Arc length along standard meridian
--M = M0 + y/k0;//Arc length along standard meridian.
set @mu = @M/(@a*(1.0 - @esq*(1.0/4.0 + @esq*(3.0/64.0 + 5.0*@esq/256.0))));
--mu = M/(a*(1 - esq*(1/4 + esq*(3/64 + 5*esq/256))));
set @phi1 = @mu + @e1*(3.0/2.0 - 27.0*@e1*@e1/32.0)*SIN(2.0*@mu) + @e1*@e1*(21.0/16.0 - 55.0*@e1*@e1/32.0)*SIN(4.0*@mu); --Footprint Latitude
--phi1 = mu + e1*(3/2 - 27*e1*e1/32)*Math.sin(2*mu) + e1*e1*(21/16 -55*e1*e1/32)*Math.sin(4*mu);//Footprint Latitude
set @phi1 = @phi1 + @e1*@e1*@e1*(SIN(6.0*@mu)*151.0/96.0 + @e1*SIN(8.0*@mu)*1097.0/512.0);
--phi1 = phi1 + e1*e1*e1*(Math.sin(6*mu)*151/96 + e1*Math.sin(8*mu)*1097/512);
set @C1 = @e0sq*POWER(COS(@phi1),2.0);
--C1 = e0sq*Math.pow(Math.cos(phi1),2);
set @T1 = POWER(TAN(@phi1),2.0);
--T1 = Math.pow(Math.tan(phi1),2);
set @N1 = @a/SQRT(1.0-POWER(@e*SIN(@phi1),2.0));
--N1 = a/Math.sqrt(1-Math.pow(e*Math.sin(phi1),2));
set @R1 = @N1*(1.0-@e*@e)/(1.0-POWER(@e*SIN(@phi1),2.0));
--R1 = N1*(1-e*e)/(1-Math.pow(e*Math.sin(phi1),2));
set @D = (@x-500000.0)/(@N1*@k0);
--D = (x-500000)/(N1*k0);
set @phi = (@D*@D)*(1.0/2.0 - @D*@D*(5.0 + 3.0*@T1 + 10.0*@C1 - 4.0*@C1*@C1 - 9.0*@e0sq)/24.0);
--phi = (D*D)*(1/2 - D*D*(5 + 3*T1 + 10*C1 - 4*C1*C1 - 9*e0sq)/24);
set @phi = @phi + POWER(@D,6.0)*(61.0 + 90.0*@T1 + 298.0*@C1 + 45.0*@T1*@T1 - 252.0*@e0sq - 3.0*@C1*@C1)/720.0;
--phi = phi + Math.pow(D,6)*(61 + 90*T1 + 298*C1 + 45*T1*T1 -252*e0sq - 3*C1*C1)/720;
set @phi = @phi1 - (@N1*TAN(@phi1)/@R1)*@phi;
--phi = phi1 - (N1*Math.tan(phi1)/R1)*phi;
set @latitude = FLOOR(1000000.0*@phi/@drad)/1000000.0;
set @lng = @D*(1.0 + @D*@D*((-1.0 - 2.0*@T1 - @C1)/6.0 + @D*@D*(5.0 - 2.0*@C1 + 28.0*@T1 - 3.0*@C1*@C1 + 8.0*@e0sq + 24.0*@T1*@T1)/120))/COS(@phi1);
set @lngd = @zcm+@lng/@drad;
set @longitude = FLOOR(1000000.0*@lngd)/1000000.0;
return @longitude;
end