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 |
|
andrea640
Starting Member
5 Posts |
Posted - 2011-08-09 : 18:44:56
|
| Hi guys,i would like make a question about SQLITE.I have two tables: TabNum (2 col) and TabValue (41 col)TabNum: IDN - Num1 | 162 | 313 | 27... | ....almost 2500 rowsTabValue: IDV - R1 - R2 - R3 - R4 - R5 -..R16......R27.... R31......R401 | 3 | 18 | 25 | 0 | 9 | ...| 7 | ....| 53|....| 2 |........|89|2 | 8 | 11 | 21 | 8 | 2 | ...| 1 | ....| 59|....| 1 |........|19|3 | 1 | 16 | 75 | 1 | 4 | ...| 4 | ....| 54|....| 3 |........|29|4 | 0 | 10 | 66 | 7 | 7 | ...| 9 | ....| 83|....| 4 |........|11|5 | 6 | 13 | 14 | 1 | 9 | ...| 7 | ....| 13|....| 6 |........|14|.....ecc...ecc...almost 20.000 rowsI make a join like this:Select tabNum.NUM, ('R' || tabNum.NUM) from TabNum,TabValue where TabValue.IDV=3So if NUM=16...i would get field name R16...and so get value R16 from TabValue that is 4So if NUM=31...i would get field name R31...and so get value R31 from TabValue that is 3So if NUM=27...i would get field name R27...and so get value R27 from TabValue that is 54and my question is: Is it possible with SQLITE create a column name dynamically and get value without use a vb o c++ code?Is it possible with MS SQL SERVER ?Thanks a lot.. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-08-09 : 20:51:57
|
i can't answer you on SQLITE, but in MS SQL, you will need to use dynamic SQL. Take a look here http://www.sommarskog.se/dynamic_sql.html KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
andrea640
Starting Member
5 Posts |
Posted - 2011-08-10 : 06:32:24
|
| Thank you for all |
 |
|
|
|
|
|