View previous topic :: View next topic
|
Author |
Message |
Shobana Bhaskar
New User
Joined: 02 Mar 2007 Posts: 35 Location: Pennsylvania, US
|
|
|
|
Hi all,
I need to insert values from table1 into table2 as below.
Table1:
Col1 Col2
ValA 1000
ValB 2000
ValC 3000
Table2:
ValA ValB ValC
1000 2000 3000
Here Col1 and Col2 are the columns of table1 and ValA, ValB, ValC are columns of table2.
ie.The Column names of table2 are values in Col1 of Table1. I need to insert data in the way i have shown above. Please help me!!
Thanks |
|
Back to top |
|
|
Jash_br
New User
Joined: 30 Mar 2007 Posts: 5 Location: Chennai
|
|
|
|
Hi Shobana,
U mean pivoting ? Hope you can use case statements as for each column.
Insert into table2
select
case col1 = valA then 1000 end
,case col1 = valB then 2000 end
,case col1 = valC then 3000 end
from table1
Try if this helps |
|
Back to top |
|
|
ragganga
New User
Joined: 22 Jan 2007 Posts: 18 Location: bangalore
|
|
|
|
Hi Shobana,
Select a record from Table1 using Cursor method then insert into Table2 using Insert command.
Synatx for Cursor and Insert you can find it in forum or any web site |
|
Back to top |
|
|
|