Inserting Data from one database table to different Database table.
we can insert or copy data from one database table to another table of different database in SQL Server 2008 using following query keeping one thing in mind that the datatype of columns in both the tables should be same.
INSERT INTO DataBaseB.dbo.Table2 (column1, column2) SELECT column1, column2 from DatabaseA.dbo.Table2
Inserting Data in same database.
We can copy all columns from one table to another, existing table use below query:
INSERT INTO table2 SELECT * FROM table1;
Or we can copy only the columns we want to into another table, from existing table with the help of below query:
INSERT INTO table2 (columnname(s)) SELECT columnname(s) FROM table1;
0 Comment(s)