Carl Carl - 6 days ago 6
SQL Question

Edit sql field type

I have a table who is filled by thousands of registers, so I don´t want to affect them. I want to change type of column:

Table:

-----------------
TrainingHours
-----------------
Id int(Primary key)
Hours decimal(18,0)


in SQL I can just add design table and changed it manually, but I need to change it with script code to get something like

Hours decimal(18,2) //instead (18,0)


How can I make this change without sql designer?

Answer

You can use alter table

ALTER TABLE TrainingHours ALTER COLUMN Hours decimal(18,2)
Comments