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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Question and... mission impossible

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 - Num
1 | 16
2 | 31
3 | 27
... | ....
almost 2500 rows

TabValue:
IDV - R1 - R2 - R3 - R4 - R5 -..R16......R27.... R31......R40
1 | 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 rows

I make a join like this:

Select tabNum.NUM, ('R' || tabNum.NUM) from TabNum,TabValue where TabValue.IDV=3

So if NUM=16...i would get field name R16...and so get value R16 from TabValue that is 4
So if NUM=31...i would get field name R31...and so get value R31 from TabValue that is 3
So if NUM=27...i would get field name R27...and so get value R27 from TabValue that is 54

and 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]

Go to Top of Page

andrea640
Starting Member

5 Posts

Posted - 2011-08-10 : 06:32:24
Thank you for all
Go to Top of Page
   

- Advertisement -