How to ALTER multiple columns at once in SQL Server
This is not possible. You will need to do this one by one.You could:
- Create a Temporary Table with your modified columns in
- Copy the data across
- Drop your original table (Double check before!)
- Rename your Temporary Table to your original name
Doing multiple ALTER COLUMN
actions inside a single ALTER TABLE
statement is not possible.
See the ALTER TABLE
syntax here
You can do multiple ADD
or multiple DROP COLUMN
, but just one ALTERCOLUMN
.
As others have answered, you need multiple ALTER TABLE
statements.
Try following:
ALTER TABLE tblcommodityOHLC alter column CC_CommodityContractID NUMERIC(18,0);ALTER TABLE tblcommodityOHLC alter column CM_CommodityID NUMERIC(18,0);