How to move a row from one table to another table.

Posted by Sathiya_Narayanan under Sql Server on 10/15/2012 | Points: 10 | Views : 1408 | Status : [Member] | Replies : 1
Hi,

How to move specific row from one table to another table, two tables has same table structure.

Any body know please guide on this.




Thanks,

SATHIYANARAYANAN


Responses

Posted by: Sourabh07 on: 10/15/2012 [Member] Starter | Points: 25

Up
0
Down
Let us take an example...I am declaring two tables with similar structure format...i.e. Table1 and Table2

Table1 contains column : id and name

Table2 contains column : code and data


Table1 consists follwing rows:

id name
----------- -------------
1 A
2 B
3 C

Now, insert the rows of the Table1 into the Table2 use the following query:


Insert into Table2 (code,data)
Select id,name from Table1

Select * from Table2



Output :

code data
----------- --------------
1 A
2 B
3 C



Sourabh07

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response