views:

9

answers:

1

Using the SQL Server Import and Export wizard in Management Studio 2005 I've encountered a big problem. After selecting a set of tables whose data I want to copy (specifying Delete Rows in Existing Tab and Identity Insert in the mappings) I execute the wizard and my rows from one database are nicely copied into my identical but previously empty database with the same schema.

However I've found that not all the columns are being copied correctly. Columns of data type "xml" are being replaced with a blank string (""). This is specific enough that if the column was previously null it will be copied as null, but if it contained XML data the copied column will be a blank string (which caused immediate parsing exceptions in my code).

There is no schema for the XML columns, they are just free form. The simplest table is below (column names changed to protect the guilty):

CREATE TABLE [dbo].[Joes]
(
    [JoeID] [int] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar](20) NOT NULL,
    [Wives] [xml] NOT NULL CONSTRAINT [DF_Roles_Permissions] DEFAULT ('<wives />'),
    CONSTRAINT [PK_Joes] PRIMARY KEY CLUSTERED ([JoeID] ASC)
)

I had to ensure Identity Insert was turned on in the mappings to copy the rows without error, is there another setting I'm missing to ensure XML data is copied?

A: 

Trial and error suggests that the "Optimize for many tables" option is the source of this issue. This option was automatically checked only when a large number of tables where selected.

I am still accepting answers if they can link this to a known issue, since if I can I don't want to go forward unless I'm sure the import is going to work correctly as the dataset increases or changes in structure.

David