473,803 Members | 3,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2878

"Jarrod Morrison" <ja*****@ihug.c om.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.c om.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
22149
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 application server can talk to the database. I've determined the failure occurs when the the following statement is executed: cstmt.execute(); (due to the failure of println statements placed afterwards). I get the following error after trying to...
4
3193
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 Throwable as an OUT parameter and what datatype should I use in the CREATE PROCEDURE and DROP PROCEDURE statements? Here's what I tried: - the method signature for the stored procedure included: Throwable throwable
8
7948
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 created a temporary database with a tables space. Verified that DECLARE GLOBAL TEMPORARY TABLE TEMP (A INTEGER); INSERT INTO SESSION.TEMP VALUES(10); SELECT A FROM SESSION.TEMP; works from a query tool.
2
5464
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
0
9703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9565
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10550
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9125
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2972
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.