473,395 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Synatx In Stored Procedure

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


Jul 20 '05 #1
3 2861

"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
Jul 20 '05 #2
Hi

It is not clear what you want to do here

If your stored procedure uses a SELECT statement the front end application
should be able to handle it

SELECT LocationID, LocationDesc
FROM #MyTable

If you post DDL (Create table statements, use the scripting options in EM or
Query Analyser to get this), Example data using insert statements, and you
current procedure, we may be able to offer more help.

John

"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

Jul 20 '05 #3
What do you want in the client?
If you want all the values concatenated into a comma sparated list
then providing there aren't too many

declare @s varchar(8000)
select @s = coalesce(@s+',','') + LocationID
from #tbl

select @s

If you just want the values to display in a dropdown list for instance
then
select LocationID
from #tbl
will do.

In both examples you will have to open a recordset from the client -
in the first you could use an output variable.
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
4
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the...
8
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.