Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Posts
    49

    Unanswered: How to get recordset from only last SELECT stmt executed???

    How to get recordset from only last SELECT stmt executed???

    this is part of my code.. in T-Sql


    Create proc some mySp
    ...
    AS
    ...
    set nocount on
    if (@SelUserID is null)
    select 0
    else if (@SelUserID = @userID)

    select 1

    else
    begin

    select * -- select a.
    from dms_prsn_trx_log
    where @incNo = ult_incid_no and
    prsn_trx_no = 10 and
    trx_log_txt = @logText
    if (@@rowcount != 0)
    set @isForwardedByUser = 1
    select 2 -- select b. I NEED This value.

    end
    set nocount off
    GO

    here it executes select a, b.
    But, I want mySp return last executed select result. which is here "select 2"

    I thought set nocount ON does that, but it doesn't.
    How can I do???
    MCSD .NET, SCJP, SCJWD

  2. #2
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    ANytime you select values without an assignment operator, they will be returned as part of the rowset. It sounds like you want to check for the existence of one rowset before selecting the second. So how about this:


    if exists (select 1
    from dms_prsn_trx_log
    where @incNo = ult_incid_no
    and prsn_trx_no = 10
    and trx_log_txt = @logText)
    begin
    select b.
    end
    else
    select a.
    end

  3. #3
    Join Date
    Apr 2004
    Posts
    49
    Thank you it helps..
    So, you means there is no such switch thing on off?
    I thought it has...-.-
    MCSD .NET, SCJP, SCJWD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •