I have a field in a SQL Server 2012 database that is currently decimal(30,20) because that is the format of the data provider. However, that large of a decimal is completely unnecessary and would like to trim it down to something like decimal(16,7) considering this table has millions of rows.
I tried the following SQL:
alter table mytable alter column mycolumn decimal(16,7)
But that resulted in the error:
Arithmetic overflow error converting numeric to data type numeric.
What is the best way to change this field? I obviously realize the error is occurring because the values in the column exceed the new precision. What I'm wondering is if there is a script that can cut off any digits past the 7th decimal point and then convert the column data type?