View previous topic :: View next topic
|
Author |
Message |
mani_shankh
New User
Joined: 27 Apr 2005 Posts: 2 Location: new delhi
|
|
|
|
hi....
i want to insert data from one column of a table to another column of another table. the datatype and data length of both columns of the tables are same.
is it possible and if possible then how?
help appreciated.
thanx :roll: |
|
Back to top |
|
|
gnagakishore
New User
Joined: 26 Mar 2005 Posts: 25 Location: Hyderabad
|
|
|
|
u can create view from both the tables so that the view may contain
the required column |
|
Back to top |
|
|
ovreddy
Active User
Joined: 06 Dec 2004 Posts: 211 Location: Keane Inc., Minneapolis USA.
|
|
|
|
Hi Mani,
You can use an insert statement as follows...
TO INSERT ONLY ONE COLUMN:
INSERT INTO TAB1(COL1) SELECT COL2 FROM TAB2 WHERE <COND>;
TO INSERT ALL COLUMNS:
INSERT INTO TAB1 SELECT * FROM TAB2 WHERE <COND>;
(BOTH TAB1 AND TAB2 HAVE THE SAME STRUCTURE)
Thanks,
Reddy. |
|
Back to top |
|
|
vasanthanc
New User
Joined: 01 Apr 2005 Posts: 58
|
|
|
|
but mani, u didnt mention about the other columns. Are there values in other columns and u need to insert data in existing records or to insert them as new records?? |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
hi frnd,
since inserting the data in two tables with same field is easy as like
insert into tablename values(select ....);
if any particular column is to be inserted check ur constraint and then insert bcz of null value in other fields will throw some error. |
|
Back to top |
|
|
paulstephen
New User
Joined: 20 Oct 2005 Posts: 20 Location: Chennai
|
|
|
|
Set some triggers |
|
Back to top |
|
|
|