tags:

views:

2537

answers:

3

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

+1  A: 

Go to enterprise manager, design table, click on your field.

Make a decimal column

In the properties at the bottom there is a precision property

qui
This will re-create the table.
Alexander Kojevnikov
In that case, dont do that then :p
qui
A: 

None that I'm aware of. You will have to modify your table the usual way (create a temp table, copy over the data, remove the old table, and finally rename the temp table).

UPDATE: This can of course be automated by the SQL Server Management Studio, follow the steps outlined by qui.

Alexander Kojevnikov
+5  A: 

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 loosing data if the precision is lower.

VanSkalen
This worked for me when increasing the precision for a decimal(18,2) to decimal(18,3).
Junto