declare @iRows int ; Select .... into #temptable from ... set @iRows = @@rowcount -- @iWantCountOnly is parameter to so only the rows are returned. if @iWantCountOnly = 1 then select @iRows ; else Select * from #temptable; select @iRows ; -- if you want both values end if ;>
>-- SP_1 >select .... -- a really complex query >return @@rowcount > > >-- SP_1Count >declare @iRows int >execute @iRows = SP_1 >select @iRows as NumberOfItems >>