By: Koen Verbeeck   |   Updated: 2021-05-20   |   Comments (1)   |   Related: More > T-

SQL INSERT INTO SELECT Examples

submited by
Style Pass
2021-05-20 13:32:57

By: Koen Verbeeck   |   Updated: 2021-05-20   |   Comments (1)   |   Related: More > T-SQL

A database engine without any data in it doesn’t seem to be very useful. In this tutorial, we’ll show you, with examples, how you can insert data into tables using the INSERT INTO statement.

To follow along with the examples, you need an empty SQL database. You can create one – if you have sufficient permissions – with the following SQL statement:

Of course, you can choose another name than "Test". To execute SQL script on a SQL Server engine, you might want to use SQL Server Management Studio, also known as SSMS. You can download this tool for free. We will also use the AdventureWorks2017 sample database to select data.

There are different methods to insert data into a table, but in this tip we’re only focusing on the INSERT INTO statement followed by a SELECT statement. For a general overview of the different options to insert rows into a table, check out the tip INSERT INTO SQL Server Command. The general syntax of the INSERT statement looks like this:

Leave a Comment