New Column in Derived Transformation

  • I have to add a column LAST_UPDT_DT_KEY_NO (whose datatype is NUMBER(10,0) in target) and i have to assign today's date to that column.

    So in Derived Columns i wrote LAST_UPDT_DT_KEY_NO as Derived column's name and in derived column i kept as "add as a new column" and in expression i wrote DATEPART("year",GETDATE()) and datatype is automatically taken as four-byte signed integer and i am unable to wite anything in precision and scale.

    As i said in target table datatype is as NUMBER (10,0) i want to convert it to number. How can i do that?

  • rahulsony111 (12/21/2009)


    I have to add a column LAST_UPDT_DT_KEY_NO (whose datatype is NUMBER(10,0) in target) and i have to assign today's date to that column.

    So in Derived Columns i wrote LAST_UPDT_DT_KEY_NO as Derived column's name and in derived column i kept as "add as a new column" and in expression i wrote DATEPART("year",GETDATE()) and datatype is automatically taken as four-byte signed integer and i am unable to wite anything in precision and scale.

    As i said in target table datatype is as NUMBER (10,0) i want to convert it to number. How can i do that?

    Cast it to a numeric(10,0) in your derived column as follows:

    (DT_NUMERIC 10,0)DATEPART("year",GETDATE())

    Josef Richberg
    2009 Exceptional DBA
    http://www.josef-richberg.squarespace.com
    http://twitter.com/sqlrunner

  • sqlrunner is correct, you must cast it within the expression.

    Just a question though, why would you not store using the date data type?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Nevermind, I just saw the other threads for this question.

    Let's end this thread and continue all responses to this thread:

    http://www.sqlservercentral.com/Forums/Topic837454-148-1.aspx

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

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

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