What ar you doing with the data returned from the first two selects? Why
are you even executing them if you don;t want the results passed back to the
client?
Either you want to use the data as a parameter value in the last Select, or
to decide whether or not to even run the last Select. Either way, The Output
of a Select statement in a Stored Proc is either returned to the client or
not returned, depending on whether the output values are being assigned to
T-SQL Variables or not. If even one output value is NOT being assigned t oa
T-SQL Variable, then the Output will be returned t othe CLient.
Select @VarA = <expresssionA>, @Varb = <ExpressionB>, <ExpressionC>, etc.
From ...
If ALL The output values are being assigned to T-SQL Variables, then the
result set will NOT be sent back to the client.
Select @VarA = <ExpresssionA>,
@Varb = <ExpressionB>,
@VarC = <ExpressionC>
From ...
In the latter case, you have to be careful that the Select only generates
one row, because if it generates more than one, then the T-SQL Variables will
be populated with the values in the Last Row of the resultset, which, without
an Order By, may not be absolutely determinisitic,
Post by TomislaWI have 3 selects in my stored procedure
I am using first and second select just for calculating number of rows
three selects
Tomislaw