"Jarrod Morrison" <ja*****@ihug.com.au> wrote in message
news:bo**********@lust.ihug.co.nz...
Hi All
I have a stored procedure with a temporary table that with two columns in
it. The first column contains 3 digit numbers and the second column some
descriptive data. I was wondering what the easiest way is to output the
first column. So far i was thinking along the lines of using a loop and
combining the first column together into a single variable to output of
the stored procedure but am unsure if this is the best way to do it ? Below is
an example of the columns, i only need to output the first column from the
stored procedure in some way
LocationID LocationDesc
001 Room 1
002 Room 2
003 Room 3
Thanks
That depends what you need to do with the output. If you're going to pass
the results to a client application, then just put a simple query in the
procedure:
select LocationID
from dbo.MyTables
order by LocationID -- if necessary
The client application then deals with the results. Or you may want to use
the results in another stored procedure, in which case you can look at the
possible approaches described here:
http://www.algonet.se/~sommar/share_data.html
Finally, from what you say you may be asking how to turn values in a column
into a list. To do it in a stored procedure, a cursor is probably the best
approach, but you might find that doing it on the client side is
faster/easier.
Simon