3 resultsets in a sp. How can I choose one?

  • When I drop a table,create another table and fill it with data, the resultset showed in a view is the table´s name that I dropped.

    How can I choose the another resultset.

    Thanks

    Ricardo Frasson

  • How are you viewing the resultsets?

    If you're using ADO, you'll need to use the NextRecordset method.

    Hope this helps

    Phill Carter

    --------------------

    Colt 45 - the original point and click interface

    --------------------
    Colt 45 - the original point and click interface

  • You shouldn't end up with more than one resultset of actual data depedning on how you are doing this but you may be getting the messages back. Do you have actual data from the drop?

  • I´m Trying to open the resultset in a view, and then show it in Asp pages.

    CREATE PROCEDURE [DBO].[test10] AS

    SELECT name from sysobjects where name = 'Cadconsumo'

    IF @@ROWCOUNT > 0

    BEGIN

    DROP TABLE Cadconsumo

    END

    SELECT MES, ANO, SUBSTRING(LINHA, 1, 4) AS LINHA, SUM(KM) AS KM, SUM(COMB) AS LITROS, TMOTOR, SUM(KM) / SUM(COMB) AS Consumo

    INTO CACONSUMO

    FROM intranet.dbo.RDB

    GROUP BY MES, ANO, SUBSTRING(LINHA, 1, 4), TMOTOR

    HAVING (SUM(KM) > 0) AND (SUM(COMB) > 0)

    ORDER BY SUBSTRING(LINHA, 1, 4), MES, ANO, TMOTOR

    Select * from CADCONSUMO

    When I call this from a view, the resultset showed is:

    --------------------

    Name

    CADCONSUMO

    When I call From Query Analiser, the resultset shows 2 recordsets.

  • There are two things you might try... First, instead of

    SELECT name...

    IF @@ROWCOUNT

    Try

    IF EXISTS ( SELECT * FROM sysobjects WHERE Name = 'Cadconsumo' AND Type = 'U' )

    DROP TABLE Cadconsumo

    Second, I would probably put

    SET NOCOUNT ON

    at the beginning with

    SET NOCOUNT OFF just before

    SELECT * FROM Cadconsumo

    (Just for fun)

    Guarddata-

  • Hi Folks,

    It´s working very well !!

    Thank you for your help

    Regards

    Ricardo Frasson

Viewing 6 posts - 1 through 5 (of 5 total)

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