SQL Cast from int to decimal
DECIMAL(2) is a decimal of 2 digits before and no digits after the decimal point. That doesn't allow you to have digits after the decimal point!
DECIMAL(p,s) specification defines the number of total digits (
p) and the number of digits after the decimal point (
s cannot be larger than
p and is 0 if ommitted).
You need to use something like
DECIMAL(4,2) (4 digit total - 2 of which after the decimal point; so therefore: also 2 before the decimal point) or something like that - some digits before and some after the decimal point - then you'll see your desired result!
For details on the
DECIMAL type and its syntax, consult the MSDN Books Online topic on decimal and numeric
There are actual a couple of parameters..
- p represents the "precision" - the total number of digits before and after the decimal point.
- s represents the "scale" - the number of digits after the decimal point.
By only giving 1 parameter, you are giving the precision only.