sql-serverunicodessisisnullnon-unicode

ISNULL function in SSIS


I have a column PhoneNumber varchar(50) and i want to build an expression for a derived column PhoneNumberType varchar(50) based on below,

IF PhoneNumber <> NULL then
Set to ""Office""
Else
Set to NULL
END IF

I tried as

!ISNULL(PhoneNumber ) ? "Office" : PhoneNumber 

But i am getting an error while mapping the column as

Column PhoneNumberType can not convert between unicode and non-unicode string data types

Update : Can i just go to the advance editor of derived column component and select string [DT_STR] instead of auto generated , unicode string [DT_WSTR] data type in column properties ?

is this a good practice ?


Solution

  • Well, bellow is the answer i figured out , ISNULL() didn't work as per my requirement

    PhoneNumber=="" || LEN(TRIM(PhoneNumber)) == 0 ? (DT_STR, 4, 1252)NULL(DT_STR, 4, 1252) : (DT_STR,50,1252)"Office"