Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Stored procedure NOT return resultset?

6 views
Skip to first unread message

p_m_...@hotmail.com

unread,
May 23, 2000, 3:00:00 AM5/23/00
to
Is it possible in Microsoft SQL Server 7.0 to let a stored procedure
not return a result set? Suppose I have a stored procedure mysp:

create procedure mysp as
select * from table1 where ...;
select * from table2 where ...;
return 0;

and I only want the result set for table2 returned to the caller. Is
this possible?

Hope you can help.
Regards, Peter


Sent via Deja.com http://www.deja.com/
Before you buy.

sql...@my-deja.com

unread,
May 23, 2000, 3:00:00 AM5/23/00
to
I'm very curious as to why you would select these rows if you didn't
want them displayed to the user.
Anyway, instead of

> select * from table1 where ...;
> select * from table2 where ...;

You could create a temp table or tables and then:
>insert #temp


>select * from table1 where ...;

>insert #temp


>select * from table2 where ...;

Now nothing will be returned unless you select the rows from the temp
table. Or you could select only the rows you want displayed i.e.
>select * from #temp where SafeToView = 1

Or you could create 2 tt's and only return the results from one....

In article <8gef0v$p65$1...@nnrp1.deja.com>,

DaveSatz

unread,
May 23, 2000, 3:00:00 AM5/23/00
to
Why do the first SELECT then ?

--
--
Thanks,
David Satz
Principal Software Engineer
Hyperion Solutions
(using VB6 SP3/MTS/SQL Server 6.5 SP5a./MDAC 2.1.2.4202.3)
(Please respond to the newsgroup.)


<p_m_...@hotmail.com> wrote in message news:8gef0v$p65$1...@nnrp1.deja.com...

SLC

unread,
May 23, 2000, 3:00:00 AM5/23/00
to
Ho cares why the first select! This is obviously not meant as the entire
procedure and why go through a 5 page explanation.

Answer the question or don't bother at all.


DaveSatz <davi...@yahoo.com> wrote in message
news:e#h2WMOx$GA....@cppssbbsa02.microsoft.com...

Michael W

unread,
May 23, 2000, 3:00:00 AM5/23/00
to
You may also want to use set nocount on

Otherwise the selects into the temp table will return a record count even
though they don't return a recordset. And if you are using ADO you would
have to use NextRecordset method to bypass these record counts. At least I
did.

Michael
<sql...@my-deja.com> wrote in message news:8ges6j$320$1...@nnrp1.deja.com...


> I'm very curious as to why you would select these rows if you didn't
> want them displayed to the user.
> Anyway, instead of

> > select * from table1 where ...;
> > select * from table2 where ...;
>

> You could create a temp table or tables and then:
> >insert #temp

> >select * from table1 where ...;

> >insert #temp


> >select * from table2 where ...;
>

> Now nothing will be returned unless you select the rows from the temp
> table. Or you could select only the rows you want displayed i.e.
> >select * from #temp where SafeToView = 1
>
> Or you could create 2 tt's and only return the results from one....
>
> In article <8gef0v$p65$1...@nnrp1.deja.com>,
> p_m_...@hotmail.com wrote:

Roy Harvey

unread,
May 23, 2000, 3:00:00 AM5/23/00
to
"SLC" <a@b.c> wrote:

>Ho cares why the first select! This is obviously not meant as the entire
>procedure and why go through a 5 page explanation.
>
>Answer the question or don't bother at all.

Sometimes it is not possible to give a helpful answer without more
information. In this case my answer without additional information
is:

A SELECT that would return data to the user doesn't do anything else
besides return data to the user, so to prevent it from returning data
to the user don't include the SELECT in the stored procedure.

Not much help, is it? That is because we don't know what the real
problem is yet.

Roy

DaveSatz

unread,
May 23, 2000, 3:00:00 AM5/23/00
to
Next time someboby pay to send my son to private school I take the time to
give all the possible answers based on less than the necessary information.

--
--
Thanks,
David Satz
Principal Software Engineer
Hyperion Solutions
(using VB6 SP3/MTS/SQL Server 6.5 SP5a./MDAC 2.1.2.4202.3)
(Please respond to the newsgroup.)


SLC <a@b.c> wrote in message news:uirHwFPx$GA.208@cppssbbsa03...


> Ho cares why the first select! This is obviously not meant as the entire
> procedure and why go through a 5 page explanation.
>
> Answer the question or don't bother at all.
>
>

> DaveSatz <davi...@yahoo.com> wrote in message
> news:e#h2WMOx$GA....@cppssbbsa02.microsoft.com...
> > Why do the first SELECT then ?
> >
> > --
> > --
> > Thanks,
> > David Satz
> > Principal Software Engineer
> > Hyperion Solutions
> > (using VB6 SP3/MTS/SQL Server 6.5 SP5a./MDAC 2.1.2.4202.3)
> > (Please respond to the newsgroup.)
> >
> >
> > <p_m_...@hotmail.com> wrote in message
> news:8gef0v$p65$1...@nnrp1.deja.com...

BPMargolin

unread,
May 23, 2000, 3:00:00 AM5/23/00
to
SLC,

Who cares what your opinions are. Add something useful to the conversation or
just butt out.

If you have taken offense at the statement above, then perhaps you might
consider how your statement comes across.

Dave Satz has been a valuable contributor to these newsgroups. Can't say that I
recognize your name.

Oh, and I'm really impressed how you are hiding behind a phony e-mail reply. Too
ashamed to reveal who you really are? So, if you care to flame me, feel free to
do so, but have enough courage to reveal who you are.

---------------------------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc) which can be
cut and pasted into Query Analyzer is appreciated.

Crash

unread,
May 23, 2000, 3:00:00 AM5/23/00
to
SLC,

Your comment suggests that you don't have even a basic knowledge of SQL. It
would be well for you to take your own advice.

CRASH

SLC wrote in message ...

BPMargolin

unread,
May 23, 2000, 3:00:00 AM5/23/00
to
Peter,

I apologize in advance for the following (hopefully) mirthful answer ... I'm
sure that you have a valid reason for you question ... however my first
inclination is to reply ...

Sure, just comment out the first select

Ok, sorry, just had to post that ...

Seriously, SQL Server takes the viewpoint, not unrealistically, that if you ask
it to do something, then it should do it. The code you have posted is telling
SQL Server to return two result sets. There is no option available to override
your code.

---------------------------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc) which can be
cut and pasted into Query Analyzer is appreciated.

<p_m_...@hotmail.com> wrote in message news:8gef0v$p65$1...@nnrp1.deja.com...

p_m_...@hotmail.com

unread,
May 24, 2000, 3:00:00 AM5/24/00
to
Thanks for your help. Well sometimes you just want to know something
and in this case I just wanted to know...

Regards, Peter.

0 new messages