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.
| Author |
Topic |
|
scantoria
Starting Member
15 Posts |
Posted - 2009-12-24 : 16:09:06
|
| I have a C# class that calculate distance between two zip codes. This worked well when my data was less than 10K. now that my data is almost 3M, the process is less than desirable. The application returns a list of zip codes if I ask to get all zip codes within 100 miles of point A.I think if I create a stored procedure to perform the calculation, it will speed up my process. I have only created simple stored procedures and nothing this complex. Please advice.c# codestatic double ZipDist(double Latitude1, double Longitude1, double Latitude2, double Longitude2) { double earthsRadius = 3956.087107103049; double latitude1Radians = (Latitude1 / 180) * Math.PI; double longitude1Radians = (Longitude1 / 180) * Math.PI; double latitude2Radians = (Latitude2 / 180) * Math.PI; double longitude2Radians = (Longitude2 / 180) * Math.PI; double distance = (earthsRadius * 2) * Math.Asin( Math.Sqrt( Math.Pow(Math.Sin((latitude1Radians - latitude2Radians) / 2), 2) + Math.Cos(latitude1Radians) * Math.Cos(latitude2Radians) * Math.Pow(Math.Sin((longitude1Radians - longitude2Radians) / 2), 2) ) ); return distance; }Stephen Cantoriascantoria@msn.com |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
scantoria
Starting Member
15 Posts |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|