Is there a way to alter the precision of an existing decimal column in Sql Server?
This question is related to
sql-server
There may be a better way, but you can always copy the column into a new column, drop it and rename the new column back to the name of the first column.
to wit:
ALTER TABLE MyTable ADD NewColumnName DECIMAL(16, 2);
GO
UPDATE MyTable
SET NewColumnName = OldColumnName;
GO
ALTER TABLE CONTRACTS DROP COLUMN OldColumnName;
GO
EXEC sp_rename
@objname = 'MyTable.NewColumnName',
@newname = 'OldColumnName',
@objtype = 'COLUMN'
GO
This was tested on SQL Server 2008 R2, but should work on SQL Server 2000+.
ALTER TABLE (Your_Table_Name) MODIFY (Your_Column_Name) DATA_TYPE();
For you problem:
ALTER TABLE (Your_Table_Name) MODIFY (Your_Column_Name) DECIMAL(Precision, Scale);
ALTER TABLE `tableName` CHANGE `columnName` DECIMAL(16,1) NOT NULL;
I uses This for the alterration
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
Source: Stackoverflow.com