identity issues after a restore
I am using a backup from SQL Server 2000. I restore it to a SQL Server 2008 server and the VB application works just fine. I restore it to a different SQL Server 2000, run the same VB6 application and I get the following error: 11/15/2010 8:26:49 AM MOWIS ERROR: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert the value NULL into column 'RECORD_IDENTITY', table 'schema.table'; column does not allow nulls. INSERT fails. The settings on both SQL Server 2000 servers appear to be the same for the field and the table. The field in question is set to be an Identity. All of the SELECT statements work fine, the INSERT statement does not. The INSERT statement looks like: INSERT INTO schema.table (LOCATIONSTAMP) VALUES ('89-MOFW-DRIVE-SIM') so the field that is receiving the Null value is not in the INSERT statement, but it is an Identity, it should just get the next value.
November 15th, 2010 1:33pm

When you INSERT into a table that has an IDENTITY column, you need to specify the fields that you will be inserting into. And obviously, you would exclude your identity column in the field list because it will generate its own value. INSERT INTO <schema>.<table> (<field 1>, <field 2>, ... <field n>) SELECT <fields 1 : n, matching above list > FROM ... SQL 2008 is, I think, a little less tolerant of loose logic like you had, or there may be some global server settings that prevent you running your original script. Suggestion: Fix the script by including an INSERT field list and you'll be better prepared for future versions and upgrades.Todd C - MSCTS SQL Server 2005 - Please mark posts as answered where appropriate.
Free Windows Admin Tool Kit Click here and download it now
November 15th, 2010 2:29pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics