How to conditionally filter on a column in a WHERE clause?
问题 OK, the umpteenth conditional column question: I'm writing a stored proc that takes an input parameter that's mapped to one of several flag columns. What's the best way to filter on the requested column? I'm currently on SQL2000, but about to move to SQL2008, so I'll take a contemporary solution if one's available. The table queried in the sproc looks like ID ... fooFlag barFlag bazFlag quuxFlag -- ------- ------- ------- -------- 01 1 0 0 1 02 0 1 0 0 03 0 0 1 1 04 1 0 0 0 and I want to do