Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

2 select statements in sp

Posted on 1999-07-02
3
Medium Priority
?
242 Views
Last Modified: 2010-03-19
greetings:
if i have 2 statements in my sp [Example:]
select something from table....
if @@rowcount = 0
   select somethingelse from table 2
suppress the display of empty results. the problem i have is related to asp and the way asp calls sql server sp's.
basically if first select did not return any records asp returns empty recordset and not executing the second select statement. what am i doing wrong?
0
Comment
Question by:mishab
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
gotaquestion earned 800 total points
ID: 1096128
I would do this

declare @mycount integer

select @mycount = count(field) from table
if @mycount > 0
begin
select somethingelse from table 2
end

0
 
LVL 4

Expert Comment

by:wqw
ID: 1096129
if you're using ADO try something like

    Set rs = CreateObject("ADODB.Recordset")
    rs.Open "sp_whatever", cn
    rs.NextRecordset   '<---- Check MSDN for more info

HTH

</wqw>
0
 
LVL 4

Expert Comment

by:Gustavo Perez Buenrostro
ID: 1096130
Why don´t you send the complete code?
0

Featured Post

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

662 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question