Source Type 200 in SQL Server Import and Export Wi

2020-03-01 04:49发布

I am trying to import data from one database in a server to a new table in a different server, using SQL Server import and Export Wizard. (SQL Server Management Studio 2012)

In the wizard, I checked "Write a query to specify the data to transfer", and the SQL statement returns data containing the following four columns:

+-----------------------------------------------------------------------------+
| ID(varchar(100))  |  Title(text)  |  Description(text)  |  IsActive(tinyint)|
+-----------------------------------------------------------------------------+

I want to change the types for the new table to

+----------------------------------------------------------------------------------------+
| ID(varchar(4))  |  Title(varchar(200))  |  Description(varchar(2000))  |  IsActive(bit)|
+----------------------------------------------------------------------------------------+

So, in the "Column Mappings" page(In the "Select Source Tables and Views" page, I clicked "Edit Mappings..."), I changed the Destination Type to the above types. Then, after clicking "Next", in the "Review Data Type Mapping" page, I get an error that says "Found 3 unknown column type conversion(s). You are only allowed to save the package"

The Data type mapping shows the following information:

icon    Source Column    Source Type    Destination Column    Destination Type    Convert
----------------------------------------------------------------------------------
error   ID               200            ID                    varchar
error   Title            200            Title                 varchar
error   Description      201            Description           varchar
warning IsActive         tinyint        IsActive              bit    

Even if I don't change the data type in the "Edit Mappings..." page, I get the same error.

I don't understand what "200" means in the context of a data type, and how can I import this data to a new table in a different server?

I appreciate any help.

8条回答
在下西门庆
2楼-- · 2020-03-01 05:24

This is the bug and was just fixed in SQL SERVER 2012 SP2.

查看更多
Viruses.
4楼-- · 2020-03-01 05:28

With a bit of experimentation this error only seems to occur when you have a query as the source. The accepted answer did not work for me as copying to a flat file would result in the same error.

To solve this I put my query into a View then selected Copy From one or more Tables Or Views instead of Write a query....

I went through the wizard normally after that and my data went through with no error

查看更多
做自己的国王
5楼-- · 2020-03-01 05:33

A long-term solution (besides Microsoft fixing it) (or have they already?) is also a few links deep from the answers posted.

On the affected machine, there is an xml file that defines a code-to-value mapping for each transform type.
What is seen with the "200" & "201" causing a failure, is a missing mapping
....well, it shouldn't have come through as "200/201", but as it did, we wish it were mapped

It can be inserted manually, if you are willing to play with such configurations.

Here is where I got the answer, quite a ways down the page: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/97ff1f01-c02a-4c9a-b867-8eaecc464cfb/2012-sp1-no-longer-recognizes-common-data-types?forum=sqlintegrationservices

The mapping files are in C:\Program Files (x86)\Microsoft SQL Server\110\DTS\MappingFiles\
(or equivalent)

There is one for each type of source-to-destination transform.

For going between SQL Servers, look at ones such as
MSSQLToSSIS10.XML
MSSql9ToMSSql8.xml
MSSql10ToMSSql9.xml

Where you see

<!-- varchar -->
<dtm:DataTypeMapping >
    <dtm:SourceDataType>
        <dtm:DataTypeName>varchar</dtm:DataTypeName>
    </dtm:SourceDataType>
    <dtm:DestinationDataType>
        <dtm:CharacterStringType>
            <dtm:DataTypeName>DT_STR</dtm:DataTypeName>
            <dtm:UseSourceLength/>
        </dtm:CharacterStringType>
    </dtm:DestinationDataType>
</dtm:DataTypeMapping>

Add the "200" mapping to match such that you end up with

<!-- varchar -->
<dtm:DataTypeMapping >
    <dtm:SourceDataType>
        <dtm:DataTypeName>varchar</dtm:DataTypeName>
    </dtm:SourceDataType>
    <dtm:DestinationDataType>
        <dtm:CharacterStringType>
            <dtm:DataTypeName>DT_STR</dtm:DataTypeName>
            <dtm:UseSourceLength/>
        </dtm:CharacterStringType>
    </dtm:DestinationDataType>
</dtm:DataTypeMapping>
<dtm:DataTypeMapping >
    <dtm:SourceDataType>
        <dtm:DataTypeName>200</dtm:DataTypeName>
    </dtm:SourceDataType>
    <dtm:DestinationDataType>
        <dtm:CharacterStringType>
            <dtm:DataTypeName>DT_STR</dtm:DataTypeName>
            <dtm:UseSourceLength/>
        </dtm:CharacterStringType>
    </dtm:DestinationDataType>
</dtm:DataTypeMapping>  

Fix nvarchar and any others in the same way!

查看更多
爷的心禁止访问
6楼-- · 2020-03-01 05:38

I was able to work around this by casting character fields as char(##) in the SQL and then changing the destination data types to varchar(##). The fields might need trimming before use, but the import works.

查看更多
Rolldiameter
7楼-- · 2020-03-01 05:43

You really don't need to do any fiddling with config, views or whatever. Just save the SSIS package and execute it by double-clicking it in Explorer. This will launch the "Execute Package Utility (DTExecUI.exe in the ManagementStudio folder) which should run the package without error.

查看更多
登录 后发表回答