Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
i am having two table

table-1 :custid,custname,custadd,city,phone,pin
table-2 :custid,orderid,orderdate,amount


i want to insert table-1.custid values into table-2.custid

table-1 is having the data
table-2 is blank


how do i write the query to insert data into table-2 ?
plz Help.
Posted
Updated 26-Dec-11 21:07pm
v2
Comments
Varun Sareen 27-Dec-11 3:06am    
My vote for 3, a very novice question

Try this,



SQL
insert into table-2(custid) select custid from table-2


Thanks..
 
Share this answer
 
Comments
Nikhil Bhivgade 27-Dec-11 3:21am    
Thank's ur query worked ....
Dear Nikhil,

Use procedure which returns the Customer ID the moment it is inserted into the table1 by using the CustomerID as the out parameter.

Then the moment you will get the Customer ID save it in some variable and use it for inserting the same into table2.

Please mark this as your answer if this helps you out.

Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900