警告:由于从数据库列中检索数据可能会发生截断

Warning: Truncation may occur due to retrieving data from database column

我正在使用 SSIS 从 Oracle 导入数据集。 SSIS 给我一个警告:

Truncation may occur due to retrieving data from database column "Third Party" with a length of 28 to data flow column "Third Party" with a length of 25."

警告没有意义。目标是 SQL 服务器数据库,其中属性是 [Third Party] 作为 nvarchar(255)

为什么该工具给我这个奇怪的错误?

我试过更改 nvarchar(max) 的长度。这并没有什么不同。

select 
    case 
        when XTNL_HOS_FLG = 1 and VND_MG_APL_FLG = 0 
           then 'Host'          
        when XTNL_HOS_FLG = 0 and VND_MG_APL_FLG = 1 
           then 'Support or Manage' 
        when XTNL_HOS_FLG = 1 and VND_MG_APL_FLG = 1 
           then 'Host and (Support or Manage)'  
        else ''
    end  as "Third Party"
from 
    table1

通过右键单击源目标在您的数据流任务中查看 "Show Advanced Editor"。 然后转到 "input and output properties" 选项卡并检查列的长度。

对目标目标执行相同的操作。

根据您获取数据的方式,列的类型和长度与数据库不同。

由于您使用 SQL 命令作为源,您可以编辑命令并强制源列长度并帮助 OLEDB 源识别它。您可以使用 CAST 函数来执行此操作:

select CAST(
    case 
        when XTNL_HOS_FLG = 1 and VND_MG_APL_FLG = 0 
           then 'Host'          
        when XTNL_HOS_FLG = 0 and VND_MG_APL_FLG = 1 
           then 'Support or Manage' 
        when XTNL_HOS_FLG = 1 and VND_MG_APL_FLG = 1 
           then 'Host and (Support or Manage)'  
        else ''
    end AS NCHAR(255)) as "Third Party"
from 
    table1

我是这样做的:我使用命令 left(column,n) 来匹配输出文件。