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
 BEST POSSIBLE WAY TO QUERY

Author  Topic 

mumair
Starting Member

1 Post

Posted - 2013-01-04 : 02:39:48

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.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-04 : 02:52:08
The best approach to use here would be recursive CTE logic

see

http://msdn.microsoft.com/en-us/library/ms186243(v=sql.105).aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -