SSIS loading null values into column when using datepart in derived transformation

  • Here is the syntax using in derived transformation :

    (DATEPART("dw",[Transaction Date]) == 1 ? "Sunday" : DATEPART("dw",[Transaction Date]) == 2 ? "Monday" : DATEPART("dw",[Transaction Date]) == 3 ? "Tuesday" : DATEPART("dw",[Transaction Date]) == 4 ? "Wednesday" : DATEPART("dw",[Transaction Date]) == 5 ? "Thursday" : DATEPART("dw",[Transaction Date]) == 6 ? "Friday" : DATEPART("dw",[Transaction Date]) == 7 ? "Saturday" : "")

    Data type DT_STR  -50 

    But while loading into the database it loads null values : and datatype for the destination is varchar(50)

  • mnr123 - Wednesday, April 4, 2018 10:54 AM

    Here is the syntax using in derived transformation :

    (DATEPART("dw",[Transaction Date]) == 1 ? "Sunday" : DATEPART("dw",[Transaction Date]) == 2 ? "Monday" : DATEPART("dw",[Transaction Date]) == 3 ? "Tuesday" : DATEPART("dw",[Transaction Date]) == 4 ? "Wednesday" : DATEPART("dw",[Transaction Date]) == 5 ? "Thursday" : DATEPART("dw",[Transaction Date]) == 6 ? "Friday" : DATEPART("dw",[Transaction Date]) == 7 ? "Saturday" : "")

    Data type DT_STR  -50 

    But while loading into the database it loads null values : and datatype for the destination is varchar(50)

    What is your question?

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • mnr123 - Wednesday, April 4, 2018 10:54 AM

    Here is the syntax using in derived transformation :

    (DATEPART("dw",[Transaction Date]) == 1 ? "Sunday" : DATEPART("dw",[Transaction Date]) == 2 ? "Monday" : DATEPART("dw",[Transaction Date]) == 3 ? "Tuesday" : DATEPART("dw",[Transaction Date]) == 4 ? "Wednesday" : DATEPART("dw",[Transaction Date]) == 5 ? "Thursday" : DATEPART("dw",[Transaction Date]) == 6 ? "Friday" : DATEPART("dw",[Transaction Date]) == 7 ? "Saturday" : "")

    Data type DT_STR  -50 

    But while loading into the database it loads null values : and datatype for the destination is varchar(50)

    I don't recall if DATENAME is a function in SSIS, but I do know it is in T-SQL.   The interval type value would be the same as DATEPART, and then you wouldn't need all the logic in there at all.   Also, why varchar(50) if the longest day of the week is only 9 characters?

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply