Consider the following stored procedure :
create procedure [dbo].[MyTest] ( @p_SqlStatement nvarchar(max) )
as
begin
exec sp_executesql @p_SqlStatement
if @@ROWCOUNT = 1
begin
select 1;
end
else if @@ROWCOUNT <> 1
begin
select 0;
end
end
This stored procedure currently returns 2 datasets, one with the exec sp_executesql @p_SqlStatement
data, and the other one would be either 1 or 0. Is there a way to suppress the first dataset? I mean, would it be possible that this stored procedure returns only 1 or 0 ?
I tried adding a RAISERROR( 'MyError', 18, 1 )
right after the exec sp_executesql @p_SqlStatement
and then in the catch block select something else, but the first result set is always returned to my stored procedure caller...