Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Distance Formula SQL, error no POW

Author  Topic 

knudmt
Starting Member

12 Posts

Posted - 2010-04-22 : 12:07:51
Hello I am trying to use the distance formula in sql to show the distance between all locations in two tables. but when I do so it throws me an error: POW is not a built-in function

here is my statement

SELECT p.poiAID, p.poiBID, SQRT(POW(a.GPSLat - b.GPSLat, 2) + POW(a.GPSLon - b.GPSLon, 2))
AS distance
FROM tblPaths p
JOIN tblPointOfInterest a
ON p.poiAID = a.ID
JOIN tblPointOfInterest b
ON p.poiBID = b.ID

Any suggestions?

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-04-22 : 12:21:23
R u trying to do power of Eg: 2 to power of 2 = 4

In that case use Power and not Pow.

Go to Top of Page

knudmt
Starting Member

12 Posts

Posted - 2010-04-22 : 13:42:23
YES THAT DID IT!! thank you so much! This is honestly one of the best forums I have ever used. You have no idea how much this has helped me! Thanks again you are a life saver!
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2010-04-22 : 14:02:14
Great Circle Distance Function - Haversine Formula
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81360

CODO ERGO SUM
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-04-22 : 23:56:56
You are welcome

I am here to learn from Masters and help new bees in learning.
Go to Top of Page
   

- Advertisement -