Converting varchar to decimal baseball average

前端 未结 2 2015
闹比i
闹比i 2021-01-23 12:45

I uploaded a CSV which automatically converted all my columns to varchar. I need to convert the value 22.30 to 0.223.

alter table badv2018
    alter column [BB          


        
2条回答
  •  心在旅途
    2021-01-23 13:34

    Make it a wider value. For instance:

    alter table badv2018
        alter column [BB Percent] decimal(10, 3) 
    

    (4, 3) can only represent values from 0.000 to 9.999. You probably really want (6, 3), so 10 is overkill.

    You can then add another column with the result you want:

    alter table badv2018
        add column bb_ratio as ([BB Percent] / 100);
    

提交回复
热议问题