473,406 Members | 2,745 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,406 software developers and data experts.

Hide subquery results in stored procedure

Hi everyone, I have a stored procedure which I use to query a table.

The first part of the stored procedure uses a cursor to update a temp table
whilst the second part of the query actually retrieves information from a
database table utilising information based on the temp table.

My problem is that when I run the procedure, the cursors status is output
and therefore becomes part of the result set. I really only want the
information returned returned by the second query as my result set.

So, is it possible to hide the results of the cursor so that it does not
become part of the result set? I have tried nocount on around the cursor
routine but this does not work

Thanks in advance
Mark
Jul 23 '05 #1
4 7133
Hej John,

If I think correctly, you will to get ONLY rows returned by any second
query. The nocount option, is for hidding messages, that SQL server
brings additionaly to the query resultset (like rowcount of selected
rows).
But as far as I know, it want solve this problem that you have.
Unfortunately, I'm fighting with the same problem that you have (if I
understood you properly), so that's why I will be very happy, to here
the possible solution....

Sorry,

Mateusz

Jul 23 '05 #2
Hej John,

If I think correctly, you will to get ONLY rows returned by any second
query. The nocount option, is for hidding messages, that SQL server
brings additionaly to the query resultset (like rowcount of selected
rows).
But as far as I know, it want solve this problem that you have.
Unfortunately, I'm fighting with the same problem that you have (if I
understood you properly), so that's why I will be very happy, to here
the possible solution....

Sorry,

Mateusz

Jul 23 '05 #3
On Tue, 7 Dec 2004 13:24:18 +1300, John wrote:
Hi everyone, I have a stored procedure which I use to query a table.

The first part of the stored procedure uses a cursor to update a temp table
whilst the second part of the query actually retrieves information from a
database table utilising information based on the temp table.

My problem is that when I run the procedure, the cursors status is output
and therefore becomes part of the result set. I really only want the
information returned returned by the second query as my result set.

So, is it possible to hide the results of the cursor so that it does not
become part of the result set? I have tried nocount on around the cursor
routine but this does not work

Thanks in advance
Mark


Hi Mark (and Mateusz),

It's really hard to troubleshoot code you can't see. If you want help,
please post the following:

1. The code of the stored procedure (of course) and of any stored
procedures called from that procedure,
2. The structure of all tables used in the stored procedure (posted as
CREATE TABLE statements, including all constraints and properties, though
irrelevant columns and their constraints may be omitted),
3. Sample data that illustrates both what you are trying to accomplish and
the unwanted behaviour you are seeing (posted as INSERT statements, as I
don't have the time to manually copy your sample data),
4. The output you expect to see from the sample data,
5. A short description of the business problem you are trying to solve.
Try to describe it without assuming that I know anything about your
business, as I probably don't.

Also see http://www.aspfaq.com/5006.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Jul 23 '05 #4
Hi, thanks for your help.
The initial code it was to randomly select a row from a table by generating
a random number and associating the new number with the primary key id of my
table. I have since done it another way using the NewID() method of MSSQL

Again thanks for your help
Regards

"Hugo Kornelis" <hugo@pe_NO_rFact.in_SPAM_fo> wrote in message
news:bb********************************@4ax.com...
On Tue, 7 Dec 2004 13:24:18 +1300, John wrote:
Hi everyone, I have a stored procedure which I use to query a table.

The first part of the stored procedure uses a cursor to update a temp tablewhilst the second part of the query actually retrieves information from a
database table utilising information based on the temp table.

My problem is that when I run the procedure, the cursors status is output
and therefore becomes part of the result set. I really only want the
information returned returned by the second query as my result set.

So, is it possible to hide the results of the cursor so that it does not
become part of the result set? I have tried nocount on around the cursor
routine but this does not work

Thanks in advance
Mark


Hi Mark (and Mateusz),

It's really hard to troubleshoot code you can't see. If you want help,
please post the following:

1. The code of the stored procedure (of course) and of any stored
procedures called from that procedure,
2. The structure of all tables used in the stored procedure (posted as
CREATE TABLE statements, including all constraints and properties, though
irrelevant columns and their constraints may be omitted),
3. Sample data that illustrates both what you are trying to accomplish and
the unwanted behaviour you are seeing (posted as INSERT statements, as I
don't have the time to manually copy your sample data),
4. The output you expect to see from the sample data,
5. A short description of the business problem you are trying to solve.
Try to describe it without assuming that I know anything about your
business, as I probably don't.

Also see http://www.aspfaq.com/5006.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)

Jul 23 '05 #5

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

Similar topics

7
by: Andrew Mayo | last post by:
Here's a really weird one for any SQL Server gurus out there... We have observed (SQL Server 2000) scenarios where a stored procedure which (a) begins a transaction (b) inserts some rows into...
4
by: Trifix | last post by:
Hello all, I have a stored procedure with a parameter that I need to use in a subquery, but my query doesn't work. The stored procedure is some as: CREATE PROCEDURE dbo.Test @valore...
4
by: Kenny G | last post by:
Below is a query that I currently have. I need to produce a subquery so that the top five of the CodeCount is returned. I appreciate your help. SELECT .PX_SURGEON, .PX_CODE, Count(.PX_CODE)...
4
by: jaYPee | last post by:
I have downloaded some source code but I want this to convert the results into datagrid. dr = cmd.ExecuteReader() '**************************************** ' SHOW THE RESULTS...
6
by: Uday | last post by:
Hi everyone, I have a ASP page that triggers a db-side stored procedure. At the end of the procedure, it spits out a log file, that this ASP page reads and displays for the users. But the...
3
by: Shals | last post by:
Hi, I'm using Form and a subform control within that form. Main form is getting data from one table(Buildings) and subform is getting data from another table(BldgDataByFloor). but both the form...
4
by: Shree111 | last post by:
Can you use a stored procedure in a subquery in postgres?
7
by: blabla2006 | last post by:
I have a stored procedure that calls another stored procedure on a different server. I get the error i wrote above. The first procedure is: set @DB_NAME = (select db_name from all_servers where...
3
by: Bogdan | last post by:
Hi, I've been struggling subqueries/joins and table adapters for some time and can't find a clear answer. I have a stored procedure that returns columns from 2 tables. Two columns from the...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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...
0
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...

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.