SQL

How To Write Insert Query In SQL

Introduction

In this article, we will learn how to write a SQL insert query.

To Insert data in SQL INSERT INTO statement is used. We can use INSERT INTO in two ways either specify column name with values or only write values without column names.

Syntax

//With column name

INSERT INTO TABLE_NAME (column1, column2, ...columnN)  
VALUES (value1, value2, ...valueN);

//Without column name

INSERT INTO TABLE_NAME VALUES (value1,value2, ...valueN);

Note: You don’t need to specify the column name if we are going to insert all values in the table with the same order.

Example

The subsequent statements would create two records in the Article table.

INSERT INTO Article (Id,Title) 
VALUES ('A1', 'Introduction');

INSERT INTO Article (Id,Title) 
VALUES ('A2', 'Concept of SQL');

We can write the same query without column name,

INSERT INTO Article VALUES ('A1', 'Introduction');
INSERT INTO Article VALUES ('A2', 'Concept of SQL');
Faisal Pathan

Faisal Pathan is a founder of TheCodeHubs, .NET Project Manager/Team Leader, and C# Corner MVP. He has extensive experience with designing and developing enterprise-scale applications. He has good skills in ASP.NET C#, ASP.NET Core, ASP.NET MVC, AngularJS, Angular, React, NodeJS, Amazon S3, Web API, EPPlus, Amazon MWS, eBay Integration, SQL, Entity Framework, JavaScript, eCommerce Integration like Walmart, Tanga, Newegg, Group-on Store, etc. and Windows services.

Share
Published by
Faisal Pathan

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

2 years ago