I have the following database structure in MS SQL Server: ID, Col_A, Col_B, Col_C, etc...
All the other columns except for ID are of type Boolean. Lets say for example that Col_A = 1, Col_B = 0, Col_C = 1
I am looking for a way to return the names of the columns where the column is 1. In this example the return should look something like ID, Col_A, Col_C
There will be a dynamic number of columns, seeing as the table is altered often to add new columns and delete old ones.
Basically, I need the exact same functionality as in the following post, but as a MS Sql Server query: Select column names that match a criteria (MySQL)
The SQL Fiddle link http://sqlfiddle.com/#!2/8f4ee/12 is what I want to implement in MS SQL Server. Any ideas how I would go about it? The two functions, CONCAT_WS and GROUP_CONCAT are not recognized by MS SQL Server.
Any help would be appreciated.