Copy data from one table to another existing table in sql server - Free Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server,WCF,Entity framework snippets and tutorial

Copy data from one table to another existing table in sql server

Introduction: In this article today I will explain how we can copy data from one table to another existing table sql server
Description:  
Insert into Table2 Select * from Table1;
Syntax to copy only columns:
Insert into table2(Columns_Name, Columns_Name) select Columns_Name, Columns_Name from from table1;
Note: Here in the above query we select data from table 1 and insert it into table 2. Table 1 will be source and table2 will be target table

Example:

I have two tables:
Old_Student :
Create table Old_Student
(
Id int not null primary key,
Student_Name varchar(50),
Student_Address varchar(50),
Phone_No int
)
New_Student:
Create table New_Student
(
NId int not null primary key,
NStudent_Name varchar(50),
NStudent_Address varchar(50),
NPhone_No int
)
Here now I want to copy the record from New_Student table and insert into Old_Student.
Insert into dbo.Old_Student(Student_Name,Student_Address,Phone_No) select NStudent_Name,NStudent_Address,NPhone_No from dbo.New_Student;


Is this article helpful for you?
If yes post your comment to appreciate my work and fell free to contact me. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.

What do you think about this article?

If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.

Share this

Share on FacebookTweet on TwitterPlus on Google+


EmoticonEmoticon