data type(precision issue)

  • Hi,

    I am using the gollowing query

    Select 'update env_usage SET quantity='+cast( quantity as varchar(50))+','+' userenteredvalue= '+convert(varchar(1550),userenteredvalue ) +' where sitecode='+''''+sitecode+''''+' and year in (2006) and componentid in ('+cast(componentid as varchar(20)) +') and month='+cast(month as varchar(10))

    from backuptables..crg_input_env_usage_20Apr2007

    where sitecode='00223TR' and year in (2006) and componentid in (124,125,133,134,247,248,271,

    272,278,280,281,283,284)

    userenteredvalue column datatype is float

    quantity column datatype is decimal

    The result is:

    update env_usage SET quantity=969498.91666666700000, userenteredvalue= 1.1634e+007 where sitecode='00223TR' and year in (2006) and componentid in (133) and month=2

    I want to have quantity column in following format=969498916666667.00000

    result for sp_columns for quantity column is

    BackupTables dbo crg_input_env_usage_20Apr2007 Quantity 3 decimal 28 30 14 10 1 NULL NULL 3 NULL NULL 8 YES 106

    plz help

    satish

  • Asked and answered here

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=82747

     


    N 56°04'39.16"
    E 12°55'05.25"

  • Thanks for everybodys effort.

    I modified this part:

    cast(convert(decimal(16,0),userenteredvalue) as varchar(200)) and the query gave me the correct result

     

    Satish

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

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