Within tsql I’m calling a tsql stored procedure that returns a record set. I want to be able to tell if the record set is empty or not empty.
For some reason @@rowcount always returns 1.
What is the best way to do this?
One more thing I’m not in a position to edit this stored procedure.
Use @@rowcount in the inner stored proc, pass back out as an output paramter.
Use @@rowcount immediately after the SELECT in the inner stored proc. And call like this:
or…
Use RETURN @@rowcount in the inner stored proc immediately after the SELECT. And call like this:
Edit:
If you can’t edit the proc, you have to load a temp table and manipulate that.
@@ROWCOUNT fails because it only shows the last statement count, not the last SELECT. It could be RETURN, END (in some cases), SET etc