Home » SQL Server » SQL Server INSERT INTO

SQL Server INSERT INTO

INSERT INTO Statement

The SQL Server INSERT INTO statement is used to add new row into database table.

Syntax:

INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);

Let’s start with an example:

Note: Refer tutorials for – How to Create Table in SQL Server

Insert data into table, example:

INSERT INTO tblemp(firstName, lastName, IdentityNo, deptName, AddedON) 
VALUES('Martin','Lee','A100','IT', CURRENT_TIMESTAMP)

Another way to Insert Data into table :

Using Select statement you can Insert data into table, suppose we have one another table with few records same like as below

SQL Table

Select Data from Table

Now we will insert data from tblemp2 to tblemp table.

Syntax:

INSERT INTO table_1 (column1, column2, column3)
SELECT column1, column2, column3 FROM table_2

Example:

INSERT INTO tblemp(
firstName, lastName, IdentityNo, deptName, AddedON
) 
SELECT firstName, lastName, IdentityNo, deptName, AddedON 
FROM tblemp2

Select INTO Statement example

Hope you enjoy the post. Your valuable feedback, question, or comments about this post are always welcome or you can leave us message on our contact form , we will revert to you asap.

Recommended SQL Server Post:

SQL CREATE TABLE

SQL Server Commands

SQL REPLICATE() function

SQL IDENTITY Functions

SQL Query Optimization Technique

SQL Configuration Functions

SQL Alter table statement

SQL Keys

Leave a Reply