SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 BEST POSSIBLE WAY TO QUERY
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mumair
Starting Member

1 Posts

Posted - 01/04/2013 :  02:39:48  Show Profile  Reply with Quote

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

India
52317 Posts

Posted - 01/04/2013 :  02:52:08  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000