Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I alter the precision of a decimal column in Sql Server?

Tags:

sql-server

Is there a way to alter the precision of an existing decimal column in Sql Server?

like image 968
Andrew Jones Avatar asked Sep 23 '08 09:09

Andrew Jones


People also ask

How do I change the precision of a column in SQL?

Just put decimal(precision, scale) , replacing the precision and scale with your desired values. I haven't done any testing with this with data in the table, but if you alter the precision, you would be subject to losing data if the new precision is lower.

How do I increase the length of a decimal in SQL?

SQL CAST() inside AVG() for decimal value The CAST() is used to increase or decrease the decimal places of a value. The CAST() function is much better at preserving the decimal places when converting decimal and numeric data types.


1 Answers

ALTER TABLE Testing ALTER COLUMN TestDec decimal(16,1) 

Just put decimal(precision, scale), replacing the precision and scale with your desired values.

I haven't done any testing with this with data in the table, but if you alter the precision, you would be subject to losing data if the new precision is lower.

like image 200
VanSkalen Avatar answered Sep 22 '22 02:09

VanSkalen