3Jun/100
SQL Convert Percentage to Decimal
Here's a nice simple method to convert a percentage value to a decimal value. I had to import some tax rates for California a couple of days ago and all the values I recieved where in the format of 9.75 but our system needed them as 0.0975 so I wrote this simple update to update all the values to the correct format.
1 2 3 | DECLARE @VALUE AS VARCHAR(10) SET @VALUE = '9.75' SELECT CAST(CONVERT(DECIMAL(10,4) , (1.0 * CAST(@VALUE AS DECIMAL(10,8)) / 100)) AS VARCHAR) AS Pecentage |
