Vasanth Jack

Vasanth Jack

  • NA
  • 289
  • 35.2k

SQL Server : return column names based on a record's value

Jan 6 2017 3:05 AM
Hi,


I have one table.I want tha column names based on column values
 
|Field1 |Field2 |Field3 |Field4 |
|-------|-------|-      ------       |-------|
| 1      |  0      |    0       |1 |
 
 
now i want the field name contain zero.Is this POssible in sql server.

What I have tried:

I've been trying to do various joins against sys.columns (and sys.tables), but so far to little avail. 

Answers (3)