Showing posts with label xthere. Show all posts
Showing posts with label xthere. Show all posts

Sunday, March 11, 2012

Convert Table in Stored Procedure

I have a flat table from 1 of the clients with a lot of fields (more then 100) like this

Item F1 F2 F3 ... F(N)
--------------
100 X X
101 X

There are more 10000 records , X is the data inside the field.

I need to quickly convert it to this table

Item FieldNumber Value
---------
100 1 X
100 2 X
101 1 X

Any ideas ?

Thanks

MikhailHi,

My suggestion would be export the table into Excel, in Excel using formula, you can change either from horizontal to vertical or likewise.

After that, you can import back to database.

Regards
Ravi|||I am not sure what are you proposing..how will I do it in Excel ?

Any other ideas ?

Mikhail|||You can self join for each column


Select
Item,
FieldNumber.F1,
MyValue.F2
from
Table FieldNumber inner join Table MyValue on FieldNumber.Item = MyValue.Item

get the idea?