SSIS - 从DT_STR到int的数据转换

时间:2017-04-01 02:17:03

标签: sql-server ssis etl ssis-2012 bids

如何在SSIS数据流任务中应用以下转换

cast(gift_amount as int)/100

在派生列转换编辑器中,我无法更改数据类型。在给予0xC0049064函数时,它会出现typecast错误。

2 个答案:

答案 0 :(得分:2)

您可以使用script component

来解决此问题
  1. 添加Script Component
  2. gift_amount标记为输入列
  3. 添加Decimal或float(ex outColumn
  4. 类型的输出列
  5. 添加以下代码:(使用vb.net)

    If Not Row.giftamount_IsNull AndAlso
       Not String.IsNullOrEmpty(Row.giftamount) Then
    
        Row.outColumn = CDec(CInt(Row.giftamount) / 100)
    
    Else
    
        Row.outColumn_IsNull = True
    
    End If
    

答案 1 :(得分:2)

你应该试试

((DT_I4)gift_amount)/100

此外,在Derived Column Editor窗口中,您可以添加其他类型的强制转换 - 查看编辑器右上角的一些选项。

ssis dco editor