Integer column shows 5.00000000000000000 as value

  • INSERT WITH SELECT HAS THIS:

    ,Convert(Int,TARG_SALES) AS TARG_SALES

    Treats the column as if it were formatted decimal !!

  • mar.ko (9/4/2015)


    INSERT WITH SELECT HAS THIS:

    ,Convert(Int,TARG_SALES) AS TARG_SALES

    Treats the column as if it were formatted decimal !!

    Please supply the following information:

    CREATE TABLE statement for the table being inserted into.

    CREATE TABLE statement for the table being selected from.

    INSERT statements for the table being selected from that will demonstrate this issue.

    The exact INSERT statement that you are running that has this issue.

    For the data in the INSERT statements that you provided above, what are the results of the INSERT statement? (SELECT results from the table being inserted into)

    (Please see the first link in my signature for how to get / post data in order to get better answers, faster.)

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • mar.ko (9/4/2015)


    INSERT WITH SELECT HAS THIS:

    ,Convert(Int,TARG_SALES) AS TARG_SALES

    Treats the column as if it were formatted decimal !!

    Looks more like a rounding trick in the insert, pretty certain the column's datatype is of a decimal type.

    😎

  • My bad....the column was formatted as decimal (who did that ??!!**&&)

  • mar.ko (9/7/2015)


    My bad....the column was formatted as decimal (who did that ??!!**&&)

    If you don't know this, then you have people with improper access to your database.

    Gotta love how requesting the table DDL fixes the problem though... 🙂

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

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

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