---
title: "How to insert data in Identity Column?"  
description: "How to insert data in Identity Column?"  
author: "Anonymous User"  
published: 2010-11-12  
updated: 2013-02-10  
canonical: https://www.mindstick.com/forum/103/how-to-insert-data-in-identity-column  
category: "mssql server"  
tags: ["mssql server"]  
reading_time: 2 minutes  

---

# How to insert data in Identity Column?

Hi,\
I want to insert record in [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) and I am able to insert using insert [query](https://www.mindstick.com/blog/202/sub-query-in-sqlserver), but the [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) is that I [am unable](https://answers.mindstick.com/qa/95314/how-do-i-access-a-group-link-in-telegram-if-i-am-unable-to-access-the-link) to [insert data](https://www.mindstick.com/forum/33964/insert-data-in-datagridview-from-text-box-c-sharp) in [Identity column](https://www.mindstick.com/blog/329/add-identity-column-in-datatable-in-c-sharp).

Here is the Query which I am [writing](https://www.mindstick.com/articles/12997/5-essential-tips-on-resume-writing-for-business-analysts)

```
INSERT into tblLogin ([ID], [FirstName], [LastName], [Password) VALUES (15, N'abc', N'xyz', N'pass')
```

[Please tell me](https://www.mindstick.com/forum/33900/please-tell-me-what-are-the-technique-to-content-optimization) what is wrong in the query?

Thanks in advance.

## Replies

### Reply by Shankar M

Hi Rizvi,\
There is no problem with the query, The problem is that you cannot insert into a column that is defined as Identity column in SQLServer.\
Instead, you have to Modify the column Property Identity Specification - (Is Identity) to No. Then, your statement will work fine.\
To insert into a table EMP with Identity column where its Is Identity Property set to Yes can be done as shown.\
CREATE TABLE EMPLOYEE(EID INT IDENTITY(1,1),ENAME VARCHAR(20));\
INSERT INTO EMPLOYEE(ENAME)VALUES('SAM');\
Here, the Identity value is managed the SQL Server and we don't need to specifythe column while writing your Insert Statement.\
Regards,Shankar\

### Reply by Amit Singh

Hi Haider,\
\
Your query is correct, but the problem is that you can not [insert](https://www.mindstick.com/blog/173/executing-insert-delete-or-update-query-in-sqlserver-using-ado-dot-net) data directly into [Identity](https://www.mindstick.com/articles/13090/icon-the-identity-of-your-brand) column.\
\
All you have to do is to set Identity insert of that column on, and after you are done just set it off.\
\
Here is the script that will do what you want.\
\

SET IDENTITY_INSERT tblLogin ON

INSERT into tblLogin ([ID], [FirstName], [LastName], [Password]) VALUES (15, N'abc', N'xyz', N'pass')

SET IDENTITY_INSERT tblLogin OFF

Hope this will help you.


---

Original Source: https://www.mindstick.com/forum/103/how-to-insert-data-in-identity-column

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
