January 4, 2013 at 12:35 am
Hi,
I am working on an asp.net application with MS SQL DB. I have the following secnario
A table with User Location Information
User ID, GEOGRAPHIC POINT, LOCATION TYPE
I want to do the following:
query above table for a specific user for example userid 1
I will get all his locations
now I want to query the same table again for each of the rows returned above taking the geographic point as parameter so that I can search for any other user within a specific distance.
I know how to work with geographic point and get records within a specific distance. However I want your help in how can I loop through the records in first query and combine all resuts in one output.
What is the best apporach to this.. for example SQL query, SP, Cursors, or from ASP.net side processing. How can I acheive this? Appreciate all your help in advance.
January 4, 2013 at 12:56 am
HI Umer,
Welcome to SSC 🙂
We can certainly help you here . but for that we need table , index definition here along with some same data. it will help us to make you understand the solution.
PLease see link at my signature below "Click to get fast response of your post ".
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
January 4, 2013 at 2:34 am
You should be able to create an all-SQL solution without a CURSOR for this.
I suggest you look into CROSS (or OUTER) APPLY.
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply