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
set nocount on
if (@SelUserID is null)
else if (@SelUserID = @userID)
select * -- select a.
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.
set nocount off
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???
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
where @incNo = ult_incid_no
and prsn_trx_no = 10
and trx_log_txt = @logText)