I have a table like this:
| ID | X1 | X2 | X3 | .. | Xn |
+----+----+----+----+----+----+
| 1 | x | '' | x | '' | '' |
+----+----+----+----+----+----+
| 2 | '' | '' | x | '' | '' |
+----+----+----+----+----+----+
| 3 | x | x | x | '' | x |
+----+----+----+----+----+----+
'' = Empty string, not null
Now I want to know how many ‘x’ are in row 2 or 3 or n. Is there an easy way to achieve this?
Using MS SQL Server 2008
1 Answer