Tuesday 15 February 2011

sql server - Conditional reuse of subquery -


This can not be detected ...

There is an alternative argument in the SQL stored procedure, say id (int) . For the sake of simplicity, say, I have to return a result set with the extra ... and id = @ id , if the argument is not null. If I do not only return the result set

How do I avoid writing the 'core' of the query twice? CTE in rescue?

You can try: < @id If the null query compares your ID column then <> iTool (@id, id)

for yourself, which is always true, otherwise The parameter is used.

No comments:

Post a Comment