Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
SanthoshMReddy
Starting Member
1 Post |
Posted - 2009-09-28 : 14:18:28
|
| Hello all,I have been stuck with this problem since morning and would appreciate any help in this regard. Here is the problem:I have a huge table with say 100 columns. I query this table based on certain parameters but only select a few columns (say about 10). The columns to be selected are present in a 2nd table. For ex: table 2 will contain something like:ColumnName1 Type1ColumnName2 Type1ColumnName3 Type1ColumnName4 Type1ColumnName5 Type2ColumnName6 Type2ColumnName7 Type2So I have to select only ColumnName1, ColumnName2, ColumnName3, ColumnName4 for Type1 and ColumnName5, ColumnName6, ColumnName7 if Type2.How do I construct this query?In simple english, my query should be:Select <the columns present in Table2 for Type1> from Table1.I don't know how to populate the part: <the columns present in Table2 for Type1> dynamically. Any help is appreciated.Thanks!Santhosh |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-09-29 : 00:35:10
|
| why is the columns to be selected stored as a value in another table? is nt it enough to handle this as your front end to show only reqd values? |
 |
|
|
|
|
|