Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Insert/Update Error:Cannot insert explicit value for identity column in table 'Customers' when IDENTITY_INSERT is set to OFF.
Posted
Comments
Sergey Alexandrovich Kryukov 30-Nov-11 1:42am    
Where is the question? Code? Exception information in any form?
Look, you asked 53 questions? You probably have almost no answers if you ask like that, but you keep asking.
Why? It does not really help you.
--SA

Set IDENTITY_INSERT to ON for Primary/Identity Column of your Customers Table.

Have a look at below link for more information.
http://msdn.microsoft.com/en-us/library/ms188059.aspx
 
Share this answer
 
v2
Comments
Uday P.Singh 30-Nov-11 1:52am    
5ed :)
RaisKazi 30-Nov-11 2:12am    
Thank you Uday.
Hi,

please check identity columns in 'Customer' table. if it is autoincrement column, you should not pass value when inserting/updating 'Customer' table.

like

insert into customer(id,name)values(1,'amit');

if 'id' column is identity and autoincrement you should use below query.

insert into customer(name)values('amit');

thanks
-amit.
 
Share this answer
 
Comments
Uday P.Singh 30-Nov-11 1:51am    
5ed :)
You are getting this error because once have the ID key set as auto-increment you don't need to bother to enter manually a value for that field.

If you enter data in your database through SQl Server Management you will get that error again and again.

SQL server will manage the insertion of that field.

hope it helps :)
 
Share this answer
 
this error normally occurs when insert values to auto identity columns. if u want to insert values
SET IDENTITY_INSERT tableName ON 


please refer
http://vijaymodi.wordpress.com/2007/09/28/cannot-insert-explicit-value-for-identity-column-in-table-tbltesttable-when-identity_insert-is-set-to-off/[^]

http://www.sqlteam.com/article/how-to-insert-values-into-an-identity-column-in-sql-server[^]

hope this will help...
 
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