Paul's CASE use to build the dynamic SQL string is correct; but he's also right that people will be against Dynamic SQL! It's less efficient, generally, because of the execution plan handling - or lack of it. It can be invaluable - but if there's an alternative use that instead!