Stored Procedure returning multiple DataTables

  • Hi guys,

    I am using ADO.NET and MSSQL 2000.

    In a SP if you issue multiple "Select" statements, it will return multiple datatables. But now I just want the last result set. How can I tell MSSQL to only give me the last result set? I don't want to waste bandwidth to get back the extra ones.

    Thanks.

    Michael

  • What are the multiple SELECTs doing?  IF they are populating variables research SET @var = (SELECT ...)



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • If you are using ADO, there are methods to move between the result sets.

  • Thanks for your reply.
     
    The SP is for searching. It has three parameters and the queries are constructed with these parapmeters (eg. used in the WHERE clause).

    First I used all three parameters, if there is any matching record, I can return immediately. If nothing is found, I run another query but this time just use two parameters. If nothing is found, then use just one in the query.

    Therefore I may execute multiple SELECT statements in my SP. Hope it makes sense.

    Thanks.

  • Why not research using IF (SELECT COUNT(*) with 3 variables) <> 0 BEGIN END ELSE IF .... ???



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • Will it be expensive (in term of time) if I first test (use SELECT COUNT) before I do the real SELECT? The SELECT statement to executed will involve joining more then 10 tables.?

    Thanks for your help.

  • OW!  Instead of COUNT(*) FROM you could look at something similar to what MS does for DROP/CREATE OBJECTS..

    IF EXISTS (SELECT * FROM.. WITH 3 variables, then 2, etc...

    This will evaluate much quicker and be less expensive then COUNT(*).

    May just need to experiment and see which works better..



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • Million thanks.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply