---
title: "Why is use the IDENTITY column in the insert statement in SQL?"  
description: "Why is use the IDENTITY column in the insert statement in SQL?"  
author: "Ashutosh Patel"  
published: 2023-03-22  
updated: 2023-03-22  
canonical: https://www.mindstick.com/forum/157532/why-is-use-the-identity-column-in-the-insert-statement-in-sql  
category: "mssql server"  
tags: ["mssql server", "sql server", "sql"]  
reading_time: 2 minutes  

---

# Why is use the IDENTITY column in the insert statement in SQL?

Why is use the [IDENTITY column](https://www.mindstick.com/forum/103/how-to-insert-data-in-identity-column) in the [insert](https://www.mindstick.com/blog/173/executing-insert-delete-or-update-query-in-sqlserver-using-ado-dot-net) [statement in SQL](https://www.mindstick.com/forum/33706/what-is-the-difference-between-having-clause-and-group-by-statement-in-sql-server)?

## Replies

### Reply by Krishnapriya Rajeev

The *[IDENTITY](https://www.mindstick.com/articles/13090/icon-the-identity-of-your-brand)* [column](https://www.mindstick.com/forum/33860/how-to-calculate-column-summary-in-sql-server) is used in the *INSERT* statement in [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database) to generate a unique value for a particular column in a table. When a new row is inserted, the *IDENTITY* column will automatically assign a new and unique value for that column. The user doesn't have to manually input a unique value and check if each row in the table has a unique identifier.

They are used as a primary key, a foreign key, a timestamp, or a sequence number for auditing purposes. The IDENTITY column is completely automated and saves time and reduces the likelihood of errors in the data.

## SYNTAX:

*IDENTITY [( seed, increment)]*

**Seed:** Seed is the initial value of the column. Its default value is 1.

**Increment:** Increment is the value that is added to the identity value of the previous row and its default value is 1.

Given below is an example demonstrating the use of the IDENTITY column:

## CREATING THE TABLE:

![Why is use the IDENTITY column in the insert statement in SQL?](https://www.mindstick.com/mindstickforums/2a82c0f8-7d09-4e4e-aa84-6859859c55e1/images/321eec24-485a-4b1a-9b79-83d136504741.png)

In this example, we are creating a table called "Customers" with three columns. The "CustomerID" column is defined as an IDENTITY column with a seed value of 2 and an increment of 2. It acts as the primary key and generates a unique key for each row, starting by 2 and incrementing by 2 for each new row.

## INSERTING VALUES:

![Why is use the IDENTITY column in the insert statement in SQL?](https://www.mindstick.com/mindstickforums/2a82c0f8-7d09-4e4e-aa84-6859859c55e1/images/48317f50-6a32-4430-8a05-780fdb6cff25.png)

In this example, we left the "CustomerID" column empty because it generates a unique value automatically. The database will add a new value for this column when we execute the INSERT statement. Shown below is a resulting table of the above-mentioned commands:

| **CustomerID** | **FirstName** | **LastName** |
| --- | --- | --- |
| 2 | JAMES | HALE |
| 4 | KATE | WILSON |


---

Original Source: https://www.mindstick.com/forum/157532/why-is-use-the-identity-column-in-the-insert-statement-in-sql

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
