Microsoft ODBC SQL Server Driver SQL Server Cannot insert explicit value for identity column in table when IDENTITY INSERT is set to OFF - Support

Microsoft ODBC SQL Server Driver SQL Server Cannot insert explicit value for identity column in table when IDENTITY INSERT is set to OFF

From Support

Jump to: navigation, search
If you have a question or seek clarification, please call Technical Support.

Problem:

If you get the following ODBC error when trying to insert a new record into a SQL Server table with the SQL Insert statement using RPG2SQL Integrator

SQL Insert statement

insert into shippers (ShipperID) Values('4')

ODBC Error

[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert explicit value for identity column in table 'table name' when IDENTITY_INSERT is set to OFF.

Solution:

You need to omit the IDENTITY column from the table INSERT statement. If the insert is being used as part of a stored procedure, you can then use @@IDENTITY field to get the assigned SQL Server assigned IDENTITY value for subsequent table inserts.

Personal tools