BoulderBum
Programmer
I've set up a stored procedure like:
It works fine, but for maintainability reasons, I'd like to take a different approach and am wondering how I would do so (I don't really understand how return values work in the procedure. Is it just what is SELECTed at the end?)
Basically, I'd like to restructure the above to say:
Where either "results" would get returned or a filtered version of "results" would get returned. How would I go about doing what I want to do?
Code:
IF (some condition is true)
BEGIN
SELECT bunchOfStuff
FROM aTable
END
ELSE
BEGIN
SELECT bunchOfStuff
FROM aTable
WHERE blahBlah
END
It works fine, but for maintainability reasons, I'd like to take a different approach and am wondering how I would do so (I don't really understand how return values work in the procedure. Is it just what is SELECTed at the end?)
Basically, I'd like to restructure the above to say:
Code:
( SELECT bunchOfStuff
FROM aTable ) as results
IF( some condition is true )
BEGIN
SELECT *
FROM results
WHERE blahBlah
END
Where either "results" would get returned or a filtered version of "results" would get returned. How would I go about doing what I want to do?