Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
Cannot insert explicit value for identity column in table 'PageGroups' when IDENTITY_INSERT is set to OFF.


What is this?

[Edit]Shouting removed[/Edit]
Posted
Updated 5-Apr-13 0:46am
v2
Comments
[no name] 5-Apr-13 7:08am    
It means exactly what it says. You are trying to insert a value into a column that is auto incremented.

1 solution

You can insert explicit value for identity column in SQL
as
1. First set IDENTITY_INSERT ON for Table
2. Insert the vlues by specifying column name note that you must have to specify the column name .
3. set IDENTITY_INSERT OFF for Table



SET IDENTITY_INSERT TableName ON

INSERT INTO TableName
(ID,
Name,
Age)
VALUES (20,
'Pankaj',
24)

SET IDENTITY_INSERT TableName OFF
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900