Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

Failure inserting into the read-only column and SET IDENTITY_INSERT ON

06 December,2014 by Tom Collins

Question: I’m using the Import and Export Wizard to transfer data and complete a Data Import from one SQL table to another SQL table.  The job keeps failing with this SQL error message reported:

Messages Error 0xc0202049: Data Flow Task 1: Failure inserting into the read-only column "ItemID". (SQL Server Import and Export Wizard)

Error 0xc0202045: Data Flow Task 1: Column metadata validation failed. (SQL Server Import and Export Wizard)

It looks like I can’t import identity columns and timestamp columns. How can I fix?

Answer:   The workaround for this problem is to use SET IDENTITY_INSERT ON.  This code will allow values to INSERT into a table identity column.

How to use SET IDENTITY_INSERT ON

 

SET IDENTITY_INSERT  MyTable ON
---Complete the Import Operations
---When Data import completes  set identity insert off
SET IDENTITY_INSERT  Mytable OFF


Read More on topics related to SET IDENTITY_INSERT

SQL Server – Aggregate expression containing an Outer Reference


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on Failure inserting into the read-only column and SET IDENTITY_INSERT ON


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer