What should be the best way to store a percent value in SQL-Server?

You should use decimal(p,s) in 99.9% of cases.

Percent is only a presentation concept: 10% is still 0.1.

Simply choose precision and scale for the highest expected values/desired decimal places when expressed as real numbers. You can have p = s for values < 100% and simply decide based on decimal places.

However, if you do need to store 100% or 1, then you’ll need p = s+1.

This then allows up to 9.xxxxxx or 9xx.xxxx%, so I’d add a check constraint to keep it maximum of 1 if this is all I need.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)