Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 1st, 2005, 06:45 AM
Registered User
 
Join Date: Jul 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default multiple sql statement

Hi there,

i am a starter for SQL server, i wonder someone of you could help me out as i am struggling to execute second select statement based on the first sql statements result.

i have two sql statement, say the first returns the customer record,if i get the result then exit the SP otherwise try for another select statement for an agent.

immediate response will highly be appreciated.

regards
ibs
Reply With Quote
  #2 (permalink)  
Old July 1st, 2005, 09:13 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

After your first select statement check the @@rowcount variable:

IF @@rowcount > 0
   return
Else
   Run your second query here ....

Reply With Quote
  #3 (permalink)  
Old July 1st, 2005, 09:44 AM
Registered User
 
Join Date: Jul 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi jbenson001,

thanks a million ! that work very well for me.

cheers
ibs


Reply With Quote
  #4 (permalink)  
Old July 1st, 2005, 10:02 AM
Registered User
 
Join Date: Jul 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

can you please also let me know how to handle this from my ASP page, when i try to call this SP , works fine for the first query but when i try to give username/password for the second select statment its not returning nothing on my asp page.

whereas i can see the result returned back in sql-analyser.

could you see my point ?
Reply With Quote
  #5 (permalink)  
Old July 1st, 2005, 10:08 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I would need to see your code to find out what you are trying to do.

Jim

Reply With Quote
  #6 (permalink)  
Old July 1st, 2005, 10:27 AM
Registered User
 
Join Date: Jul 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Jim,

its basically a login page, two types of customers trying to access one single login, say type A,typy B customers.

when tpye A customer try to login, i will be using first select statement which takes username/password and returns back the record, if this query returns nothing than i try for the second statement assuming that this is type B customer, if it matches than return back the record.


it works very fine in Query Analyzer but through ASP page its not,
it is working fine for the first type A , i beleive its only referring to the first select statement all the time.

if this is not cleared, i would than try to post my code then
.

thanks much
ibs



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
update multiple column based on case statement?? vinod_yadav1919 SQL Server 2000 6 July 3rd, 2008 07:29 PM
multiple updates in one statement rashi Access 1 December 21st, 2007 01:05 AM
convert a SQL Statement from MS Access to a SQL Corey Access 6 March 28th, 2007 12:33 PM
Statement for Multiple Filters in SQL mckly Pro VB Databases 1 August 2nd, 2004 01:53 PM
Refer to multiple databases in one SQL statement JimPaum Pro VB Databases 5 June 25th, 2003 08:57 AM



All times are GMT -4. The time now is 02:06 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.