How to Insert Data Using Select Query in SQL Server 2005

This guide can be used to insert data into database using select query.

INSERT INTO first_table

(column1, column2)

SELECT column1, column2 FROM second_table

Using above syntax, all data in second_table will be copied into first_table.

You can also add where keyword.

INSERT INTO first_table

(column1, column2)

SELECT column1, column2 FROM second_table

WHERE id > 1000

Keywords:

  • sql server 2005

Leave a Reply

Your email address will not be published. Required fields are marked *