Can't figure this out...
Sql stored procedure has an optional argument, say an id(int). For simplicity sake, say, I have to return a result set with extra ...and id=@id check if argument is not null. If not I just return the result set.
How do I avoid writing the 'core' of the query twice? CTE to the rescue?