How to Insert Records Into a Table in SQL Server

Here is a template that you can use in order to insert records into a table in SQL Server:

INSERT INTO [database_name].[table_schema].[table_name] (column1,column2,column3,...)

VALUES

('column1_value1', 'column2_value1', ...),
('column1_Value2', 'column2_value2', ...),
.
.
('column1_valueN', 'column2_valueN', ...)

Let’s now review an example to see how to apply the above syntax in practice.

The Example

For demonstration purposes, let’s create an empty table in SQL Server, where:

  • The database name is: TestDatabase
  • The table name (with the schema) is: dbo.Person
  • The table would also contain 3 columns: FirstName, City and Age

Let’s run the following query to verify that the ‘Person’ table is currently empty:

SELECT * FROM [TestDatabase].[dbo].[Person]

As you can see, there are no records under the ‘Person’ table:

Empty table

The ultimate goal is to insert the 4 records below into the table:

FirstNameCity Age
BillLondon20
MaryNew York73
MartinLondon27
RobGeneva35

Insert Records Into the Table in SQL Server

The query below can be used to insert the 4 records into the ‘Person’ table (note that you should not place a comma after the closing bracket of the last value):

INSERT INTO [TestDatabase].[dbo].[Person] (FirstName,City,Age)

VALUES

('Bill','London',20),
('Mary','New York',73),
('Martin','London',27),
('Rob','Geneva',35)

After running the above query, the 4 records would be inserted into the ‘Person’ table.

To verify that the records were added to the table, let’s run the following SELECT query:

SELECT * FROM [TestDatabase].[dbo].[Person]

You’ll now see the newly inserted records:

How to Insert Records Into a Table in SQL Server

Insert Additional Records to the Table

You can insert additional records to the table at anytime using the same technique as reviewed above.

For example, let’s insert two additional records to the ‘Person’ table:

INSERT INTO [TestDatabase].[dbo].[Person] (FirstName,City,Age)

VALUES

('Maria','Paris',42),
('Jon','Toronto',51)

After running the query, the two additional records will be inserted into the ‘Person’ table.

Let’s rerun the SELECT query:

SELECT * FROM [TestDatabase].[dbo].[Person]

As you can see, the two additional records were indeed inserted at the bottom of the table:

Insert Records Into a Table in SQL Server

You may also want to check the following guide that explains how to delete records from a table in SQL Server.