all groups > sql server programming > july 2003 >
You're in the

sql server programming

group:

Grouping....SQL Server or VB Code?



Grouping....SQL Server or VB Code? CR Douglas
7/3/2003 10:41:51 PM
sql server programming: I have a grouping question...

I have two tables - State and Region. They are related by the regionID

I have a VB form that has a dropdown box. I would like to have the
region and state listed in the box like so:

Region1
-State
...
-State
Region2
- State
...
- State
Region3
- State
...
- State

and so on....

Is there a SQL function that will display this or is this something I
will need to do with the code to walk through the returned data and
format it this way??

Thanks in advance...
-----
CR Douglas
hpjunglecat at yahoo dot com

*** Sent via Developersdex http://www.developersdex.com ***
Re: Grouping....SQL Server or VB Code? SriSamp
7/4/2003 11:44:13 AM
There is no SQL function to do this, but you can write some code that will
give you the data in this format. Essentially you require an hierarchical
display of sorts and the SQL Server BOL has an example (search for Expanding
Hierarchies). You can also write a code based around a cursor and a
temporary table (since your levels are restricted to only 2).
--
HTH,
SriSamp
Please reply to the whole group only!
http://www32.brinkster.com/srisamp

[quoted text, click to view]

AddThis Social Bookmark Button