Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error 0xc0202049: Data Flow Task 1: Failure inserting into the read-only column

I am using SQL Server 2008 import and export wizard. I need to import a database. I opened the SQL server import/export wizard and I went through the following actions:-

  1. for the destination I chose "SQL server native client 10".

  2. then I selected copy data from one or more tables or view.

  3. SSIS run immediately

but i got the following errors,

Operation stopped...

  • Initializing Data Flow Task (Success)

  • Initializing Connections (Success)

  • Setting SQL Command (Success)

  • Setting Source Connection (Success)

  • Setting Destination Connection (Success)

  • Validating (Error)

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

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

Error 0xc004706b: Data Flow Task 1: "component "Destination - AuditActions" (22)" failed validation and returned validation status "VS_ISBROKEN". (SQL Server Import and Export Wizard)

It seems that I can not import identity columns and timestamps columns, so how I can force these values to be imported?

like image 794
john Gu Avatar asked Jan 06 '14 11:01

john Gu


People also ask

Why is column read only sql?

This happens when the source table has an identity column which is auto-generated at source and also at the destination. Since it's auto-generated by system, import/export can't overwrite identity data and treats it as read-only column.

How do I change a column from read only in SQL?

Using SQL SERVER Management Studio: Right click on Database, select Properties. And in the Database Properties window, select Options page. In Options page, under State change Database Read Only value to False.


2 Answers

With all due respect to Kishore's answer, that approach is valid if you're modifying the packages. Since you're using the import/export wizard, the more straight forward approach would be to check the Enable Identity Insert box on the Column Mappings tab.

In the Import Export Wizard, after selecting the table for copy, click the Edit Mappings... button

enter image description here

In the resulting screen, click the Enable identity insert property and your identities will be replicated over.

enter image description here

Same net result as issuing SET IDENTITY_INSERT TableName ON & OFF but this is done automagically at build time.

like image 118
billinkc Avatar answered Oct 05 '22 18:10

billinkc


Before Importing date execute the below query to set identity insert on:

SET IDENTITY_INSERT TableName ON 

Then do the import operations.

After importing date execute the below query to set identity insert off:

SET IDENTITY_INSERT TableName OFF 
like image 36
Kishore Avatar answered Oct 05 '22 19:10

Kishore