I’m trying to write a query which aggregates many rows and returns a single string value to indicate whether or not each column contains a value. It needs to examine each column and if the column contains a ‘true’ value, then concatenate the string result to indicate so.
Given (on SQL Server 2008):
Col1 | Col2
Row1: 0 0
Row2: 0 1
I need a result stating “Col1 has no true, Col2 has true” (the comma doesn’t matter).
My assumption is that I need to combine a CASE or IF statement with an ANY operator, but so far the syntax escapes me.
The following query will produce these results:
Col1 has no true, Col2 has truefor your data: