Resolved Identity Insert not working properly.

mbb

Well-known member
Joined
Jun 3, 2009
Messages
52
Programming Experience
10+
Hello,

Using a SQL Compact 3.5 database, I have a number of tables that use an identity field.

Some of those tables have predefined id values, so prior to inserting those rows I turn off identity_insert for the table and turn it back on afterwards.

The problem is that I don't think the auto_inc counter is being updated properly. If I attempt a standard insert after the preloaded rows are added, I get a duplicate key error.

Apart from not using identy columns, any ideas?



Actually I just found the answer here:

SET IDENTITY INSERT (SQL Server Compact)
That is a pain in the butt and different from SQL Server (I'm in the process of converting tables from SQL Server to SQL Compact). Beware!
 
Back
Top