SSIS包中的数据转换问题 - 文本到GUID

时间:2022-01-13 15:41:08

I am developing a SSIS package that will open an Excel spreadsheet and import the data into a database table in SQL Server 2008. When I try to convert the Excel column data type: Unicode String [DT_WSTR] to a unique identifier data type: unique identifier [DT_GUID], I get the following error:

我正在开发一个SSIS包,它将打开Excel电子表格并将数据导入SQL Server 2008中的数据库表。当我尝试将Excel列数据类型转换为:Unicode String [DT_WSTR]为唯一标识符数据类型:唯一标识符[DT_GUID],我收到以下错误:

"Invalid character value for cast specification"

“转换规范的字符值无效”

What do I need to do to resolve the conversion error?

我需要做什么来解决转换错误?

2 个解决方案

#1


5  

I used a Derived Column Transformation Editor and to wrap the excel column value in squrly brackets {} in order for the SSIS package to properly convert the Unicode String into a GUID.

我使用派生列转换编辑器并将excel列值包装在squrly括号{}中,以便SSIS包正确地将Unicode字符串转换为GUID。

#2


1  

I want to mention that this will not work with SSIS 2012 in Visual Studio. If you try to do this you get an error on the derived column transformation task. I've tried both of these:

我想提一下,这不适用于Visual Studio中的SSIS 2012。如果尝试执行此操作,则会在派生列转换任务中出现错误。我试过这两个:

(DT_GUID)[ColumnName]

(DT_GUID)("{" + [ColumnName] + "}"

(DT_GUID)(“{”+ [ColumnName] +“}”

Both of these will fail.

这两个都会失败。

However, if you simply set to ignore those errors instead of fail. It will work fine. Really spend way too much time trying to get this to work.

但是,如果您只是设置为忽略这些错误而不是失败。它会工作正常。真的花太多时间试图让这个工作。

#1


5  

I used a Derived Column Transformation Editor and to wrap the excel column value in squrly brackets {} in order for the SSIS package to properly convert the Unicode String into a GUID.

我使用派生列转换编辑器并将excel列值包装在squrly括号{}中,以便SSIS包正确地将Unicode字符串转换为GUID。

#2


1  

I want to mention that this will not work with SSIS 2012 in Visual Studio. If you try to do this you get an error on the derived column transformation task. I've tried both of these:

我想提一下,这不适用于Visual Studio中的SSIS 2012。如果尝试执行此操作,则会在派生列转换任务中出现错误。我试过这两个:

(DT_GUID)[ColumnName]

(DT_GUID)("{" + [ColumnName] + "}"

(DT_GUID)(“{”+ [ColumnName] +“}”

Both of these will fail.

这两个都会失败。

However, if you simply set to ignore those errors instead of fail. It will work fine. Really spend way too much time trying to get this to work.

但是,如果您只是设置为忽略这些错误而不是失败。它会工作正常。真的花太多时间试图让这个工作。