Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import and Export Wizard with Identity Column

I want to move data from one DB to another, while keeping the identity column values in the old DB. When I run the wizard I get a validation error "Failure inserting into the read-only column "ChannelID".

Where ChannelID is an identity column on that table. How can I override the identity functionality in order to be able to import the data?

like image 450
Elad Lachmi Avatar asked May 05 '11 06:05

Elad Lachmi


People also ask

How do I enable identity insert?

Enabling the property “Enable Identity Insert” by checking the checkbox allows the values to be inserted in the identity field. This way, the exact identity values are moved from source database to the destination table.

What is import and export data wizard?

The Import and Export wizard in SQL Server Management Studio (SSMS) assists users with copying data from one location to another. The export tasks lets you export data into another database, Excel, text files, etc. and the import tasks let you load data from other databases or sources like Excel, text files, etc.

How do I import a column in SQL?

After you select the existing tables and views to copy or review the query that you provided, if you click Edit mappings, the SQL Server Import and Export Wizard shows the Column Mappings dialog box. On this page you specify and configure destination columns to receive the data copied from the source columns.


2 Answers

You'll need to Enable identity insert. There's a check box when you click the Edit Mappings.

like image 138
House Avatar answered Sep 28 '22 03:09

House


Byte56's answer is correct - check "Enable identity insert" from the Edit Mappings screen. I just wanted to point out that the "Select Source Tables and Views" list supports multi-select, so you can hold down Shift or Ctrl to select multiple tables in the list.

like image 42
OffTheRadar Avatar answered Sep 28 '22 04:09

OffTheRadar