SQL 2000 conversion

Discussion in 'Software' started by be0, Jul 2, 2007.

  1. be0

    be0 Corporal

    Hello people,

    This is stupid but:
    update t_item_master
    set tare_weight =
    case
    when length*width*height < 5184 then convert(decimal(16,1),unit_weight)
    when length*width*height >= 5184 then convert(decimal(16,1),length*width*height/194)
    end
    Should put the data in .1 format. The server still puts it in float...
    Ex: 26.6999999999
    It is upseting me. Any ideas?
    thanks
     
  2. Publius

    Publius Sergeant

    Are you using MySQL 5.0? I don't think you are using convert() correctly. You need a USING some character set parameter in your convert().

    I think it would make more sense to use cast(). CAST(unit_weight AS decimal(16,1)). Though this is intended to be used to view data in a particular data-type that is different from the data-type defined in the table -- not to change the data-type definition in the table itself.

    If you want to change the data-type definition of the table itself, you have to use ALTER TABLE.

    Here is the syntax for convert() and cast(). http://dev.mysql.com/doc/refman/5.0/en/charset-convert.html
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds