I have one column in a table that I need to do an update datatype size. In the column the datatype is decimal(18,2).
What I need the update to do is update the datatype decimal(18,2) to decimal (18,3).
if he column has these values:
0.33
0.22
After update the size, the column values should look like this.
0.330
0.220
0.666
So i tried to alter the table column. but i am getting the below error.
Query:
Alter table Price_Hour
Alter column Value_Each decimal(18,3).
Error:
Msg 5074, Level 16, State 1, Line 1
The index 'Idx_Deleted_Absolutes' is dependent on column 'Value_Each'.
Msg 4922, Level 16, State 9, Line 1
ALTER TABLE ALTER COLUMN Value_Each failed because one or more objects access this column.
Table Design:
Table Name - Price_Hour.
ColumnName
1.GUID (PK, Varchar(36, not null)
2. PriceGUID (PK,FK,Varchar(36, not null)
3. Value_Each (decimal(18,2, null).
Could you please help me, how to alter the column size, i have 50000 records in that table also.
how to fix this error.
In Object Explorer, navigate to the table node, and then the Indexes node. Right click on the index listed and select Script Index as -> Create To -> New Window
YOu can see that Value_Each is an included column. That's what SQL is complaining about. You'll need to drop that index to change the size of that column