How to ALTER multiple columns at once in SQL Server How to ALTER multiple columns at once in SQL Server sql-server sql-server

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:

  1. Create a Temporary Table with your modified columns in
  2. Copy the data across
  3. Drop your original table (Double check before!)
  4. 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);