Insert Table Values From One Database To Another Database

Here is a SQL query for inserting data from one database table into another database table.

INSERT INTO SQL statement is used to insert data from one database table to another. The INSERT INTO can be used to transfer data from one database to other database or between two tables in the same database. 
 
Let's take an example. Here are two database tables in two different databases.
 
Table1 in DATABAE_1 
  1. CREATE TABLE table1(  
  2. [date] [datetime] NULL,  
  3. [num] [varchar](50) NULL,  
  4. [status] [nvarchar](255) NULL,  
  5. [tid] [varchar](50) NULL  
  6. )  
Table 1 in DATABAE_2 
  1. CREATE TABLE table1(  
  2. [date] [datetime] NULL,  
  3. [num] [varchar](50) NULL,  
  4. [status] [nvarchar](255) NULL,  
  5. [tid] [varchar](50) NULL,  
  6. [tname] [varchar](50) NULL,  
  7. )  
The tables can be same name or different names.
 
Here is the SQL query to insert data from table1 of database_2 to table1 of database_1. 
  1. INSERT INTO DATABAE_1.dbo.table1 ([date] ,[num] ,[status] ,[tid])  
  2. SELECT [date],[num],[status] ,[tid] FROM DATABAE_2.dbo.table1  
The INSERT INTO SQL statement is followed by the databasename.tablename ( column names) SELECT (column names) FROM databasename.tablename.
 
You can execute this table direct on a SQL Sever or from code.
 
Here is a detailed tutorial on INSERT INTO with SQL examples: 
 
 
Here is a free eBook on SQL: Basic SQL Queries