none
convert decimal to 2 digit

    السؤال

  • hi

    my column has a value like this

    1

    56

    43

    2.33333333333333333

    5.6789

    now i want that numbers who has decimal should be only 2 digit, but integer number should remain same.

    only decimal number should be round to 2

    24/ذو الحجة/1433 02:44 م

الإجابات

  • TSQL_new

    Assuming you are converting flat file to destination can you add a derived column component in your data flow task

    Your file input has 1,56,43,2.33333333333333333,5.6789

    use the expression FINDSTRING([Column 0],".",1) > 0 ? (DT_STR,20,1252)(DT_NUMERIC,10,2)[Column 0] : [Column 0]

    here column 0 is your first column. change the column names accordingly.

    Your output file will be 1,56,43,2.33,5.67

    Hope this helps

    • تم وضع علامة كإجابة بواسطة Eileen Zhao 02/محرم/1434 03:22 ص
    24/ذو الحجة/1433 06:40 م

جميع الردود

  • hi

    my column has a value like this

    1

    56

    43

    2.33333333333333333

    5.6789

    now i want that numbers who has decimal should be only 2 digit, but integer number should remain same.

    only decimal number should be round to 2

    Can you give us some more details about the problem such as:

    Are you trying this in DataFlow task or somewhere else?

    What is your source like whether its a flat file or a SQL server?


    Please mark the post as answered if it answers your question

    24/ذو الحجة/1433 02:48 م
  • i am trying in data flow task,

    the source is flat file

    24/ذو الحجة/1433 03:02 م
  • Use derived column task. Configure the task by using expression as ROUND (columname,2). It should round up to 2.

    Thaks,


    hsbal

    24/ذو الحجة/1433 06:22 م
  • TSQL_new

    Assuming you are converting flat file to destination can you add a derived column component in your data flow task

    Your file input has 1,56,43,2.33333333333333333,5.6789

    use the expression FINDSTRING([Column 0],".",1) > 0 ? (DT_STR,20,1252)(DT_NUMERIC,10,2)[Column 0] : [Column 0]

    here column 0 is your first column. change the column names accordingly.

    Your output file will be 1,56,43,2.33,5.67

    Hope this helps

    • تم وضع علامة كإجابة بواسطة Eileen Zhao 02/محرم/1434 03:22 ص
    24/ذو الحجة/1433 06:40 م