The resentment between case and nvarchar In The SSIS package

Source: Internet
Author: User
Tags ssis

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.