I have a stored procedure that returns multiple resultsets, it looks something like this
BEGIN
SET NOCOUNT ON;
SELECT c1, c2, c3
FROM t1
WHERE id = @id
IF (@@ROWCOUNT = 0)
BEGIN
SELECT c1, c2, c3
FROM t2
WHERE id = @id
END
END
I use this stored procedure in my front-end ASP.NET website.
If the first SELECT statement did not return any rows I get 2 resultsets (1st one is obviously empty) in my SqlDataReader. Is there a way to return only the resultset from the last SELECT statement?