开发者

access unkown columns of a table and insert them into a new one

开发者 https://www.devze.com 2023-02-09 09:55 出处:网络
I have a table like: item1 item2 item3item4...itemn 1234...n If I need to do some calculus with some 开发者_运维知识库variables lets saypowers and sqrt with item1,item3, and insert it in column 1 o

I have a table like:

item1 item2 item3  item4...  itemn
    1     2     3      4...      n

If I need to do some calculus with some 开发者_运维知识库variables lets say powers and sqrt with item1,item3, and insert it in column 1 of a new table, and then the same operations but with item2 and item4 and then insert it in column 2 of new table,... well something like:

new table
      column1        column2       column3      .. columnsn-1        columnsn
      item1*item3    item2*item4   item3*item5  .. itemn-1*item1  itemn *item2

But as the column names are variable (aka different tables) I dont know how to accomplish and get the values of specific columns, Could you please help me?


This is a way to extract the name and the order of the column:

select name, colorder from syscolumns where id = (select id from sysobjects where name = [tablename])

You can use this to manipulate with the data refering to its order in table instead of name

0

精彩评论

暂无评论...
验证码 换一张
取 消