Hi Folks
I'm trying to write a stored proc that will return a filtered result if the result of a subquery has data in it, or unfiltered if it doesn't.
So basically it would be SELECT A, B, C FROM TableX;
but if a subquery (SELECT D FROM TableY WHERE E = @Par1 returns rows, the query should read:
SELECT A, B, C FROM TableX WHERE C IN (SELECT D FROM TableY WHERE E = @Par1);
...But I am not sure how to set this up!
Can anyone offer some help? Thanks.
Craig
I'm trying to write a stored proc that will return a filtered result if the result of a subquery has data in it, or unfiltered if it doesn't.
So basically it would be SELECT A, B, C FROM TableX;
but if a subquery (SELECT D FROM TableY WHERE E = @Par1 returns rows, the query should read:
SELECT A, B, C FROM TableX WHERE C IN (SELECT D FROM TableY WHERE E = @Par1);
...But I am not sure how to set this up!
Can anyone offer some help? Thanks.
Craig