| Author |
Topic |
|
jkpaco
Starting Member
6 Posts |
Posted - 2010-10-19 : 21:39:07
|
| Good evening, Really hoping someone can help. I appreciate any replies. I'm tring to calculate the distance between two points, using lat and long. I keep getting a domain error. Should I be adding an if null condition to the below? If so, how can i do this?alter table testnew3add math as1.852 * 60.0 * degrees (Acos(Sin(Radians(lat))* Sin(Radians(lattwo))+ Cos(Radians(lat))* Cos(Radians(lattwo))* Cos(Radians(longtwo)-Radians(long))))thank you again for your help. jk |
|
|
naveengopinathasari
Yak Posting Veteran
60 Posts |
Posted - 2010-10-20 : 01:05:05
|
| alter table testnew3add lat int ,lattwo int ,longtwo int ,long int ,math as1.852 * 60.0 * degrees (Acos(Sin(Radians(lat))* Sin(Radians(lattwo))+ Cos(Radians(lat))* Cos(Radians(lattwo))* Cos(Radians(longtwo)-Radians(long))))Change the data type you require for the above set columnsLets unLearn |
 |
|
|
jkpaco
Starting Member
6 Posts |
Posted - 2010-10-20 : 07:19:42
|
| Thank you!!!!!I'm going to give it a try today. Appreciate you spending time on this. |
 |
|
|
jkpaco
Starting Member
6 Posts |
Posted - 2010-10-20 : 10:37:18
|
| Hi all, Are there any other suggestions? I've tried the suggestion above, and it still doesn't work. thank you, jk |
 |
|
|
jkpaco
Starting Member
6 Posts |
Posted - 2010-10-20 : 13:04:56
|
| anyone?? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-10-20 : 13:06:18
|
| what was the error you got?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
jkpaco
Starting Member
6 Posts |
Posted - 2010-10-20 : 13:09:48
|
| thank you for the response. the error was:Msg 3623, Level 16, State 1, Line 2A domain error occurred. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-10-20 : 13:14:17
|
| I think thats because its trying to do an illegal mathematical operation. are you sure the formula applied is correct?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
jkpaco
Starting Member
6 Posts |
Posted - 2010-10-20 : 13:37:24
|
| I've tested the formula multiple times, with a couple of lines. However, when using a large table of data, I get the error message. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-10-20 : 13:44:07
|
| thats because there're some values in data which when used in formula is causing it to perform illegal mathematical operation. First check expressions used inside functions like cos sin etc to for the data and check if any of them returns invalid values------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
|
|
|