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
- CREATE TABLE table1(
- [date] [datetime] NULL,
- [num] [varchar](50) NULL,
- [status] [nvarchar](255) NULL,
- [tid] [varchar](50) NULL
- )
Table 1 in DATABAE_2
- CREATE TABLE table1(
- [date] [datetime] NULL,
- [num] [varchar](50) NULL,
- [status] [nvarchar](255) NULL,
- [tid] [varchar](50) NULL,
- [tname] [varchar](50) NULL,
- )
Here is the SQL query to insert data from table1 of database_2 to table1 of database_1.
- INSERT INTO DATABAE_1.dbo.table1 ([date] ,[num] ,[status] ,[tid])
- SELECT [date],[num],[status] ,[tid] FROM DATABAE_2.dbo.table1
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

Apurv SharmaPosted Jul 1, 2021, 8:16 PM
News website ke project me user se news kese upload kerwaye me approve data dusre news ke data me nhi send ker pa raha hu