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

Viewed 187049

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

4 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.

In Oracle 10G and later following statement will work.

ALTER TABLE <TABLE_NAME> MODIFY <COLUMN_NAME> <DATA_TYPE>

If the current data type is NUMBER(5,2) and you want to change it to NUMBER(10,2), following is the statement

ALTER TABLE <TABLE_NAME> MODIFY <COLUMN_NAME> NUMBER(10,2)

Related