When I modified the SSIS package today, I encountered an inexplicable situation:
Convert SQL statements
Update [DBO]. [employee]
Set dateofchange = case when (? = ?) Then? Else getdate () End
Where [serialnumber] =?
Fill in the ole db Command component and keep reporting errors after running
"
[Ole db Command [2015] error: SSIS error code dts_e_oledberror. An ole db error has occurred. Error code: 0x80040e21.
An ole db record is available. Source: "Microsoft SQL Server native Client 10.0" hresult: 0x80040e21 Description: "invalid character value for Cast specification ".
[Ole db Command [2015] error: There was an error with input column "servicestatus2" (2087) on input "ole db command input" (2020 ). the column status returned was: "The value cocould not be converted because of a potential loss of data. ".
"
I have also used case statements before and passed them smoothly. Check the differences and find that the data type in the condition statement after case when is nvarchar, and the data type is int. The problem lies here. Microsoft also prompts you that the value "the value cocould not be converted because of a potential loss of data." cannot be converted because data may be lost.
In the process of searching for a solution, I tried to use cast, substring, and so on to make changes at the source, and the results all failed. The most reliable one is to add another lookup component and use it to compare it so that it can pass smoothly.
Attached to the previous figure, in which lookup serialnumber and servicestatus are later added.