dynamic column selection in where clause
998879Mar 25 2013 — edited Mar 26 2013Hi All,
I want to select one or more columns in where clause of sql based on user input.
There are 5 columns in the DB for flag. let's say BG1, BG2, BG3, BG4, BG5.
below is the sample data.
ID Name BG1 BG2 BG3 BG4 BG5
1 abc Y N Y N Y
2 def N Y Y N N
3 ghi Y Y Y Y N
4 mno Y Y Y Y Y
Now user want to select columns dynamically at run time. He can select multiple values. For example if he select BG1 and BG4 then query output should be as below.
ID Name BG1 BG2 BG3 BG4 BG5
1 abc Y N Y N Y
3 ghi Y Y Y Y N
4 mno Y Y Y Y Y
Thanks in advance.
Regards,
Rakesh