473,394 Members | 1,219 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,394 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 2860

"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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.