Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax for Alter Column and Add Column in same query

Is it possible to both alter a column and add a new column in the same alter table query for MSQL? I've tried looking at the below MSDN article, but it was a bit confusing to understand. I could easily do it with multiple queries, but would rather do it with one query if possible. Thanks.

http://msdn.microsoft.com/en-us/library/ms190273.aspx

like image 719
Davin Studer Avatar asked Nov 01 '25 23:11

Davin Studer


1 Answers

no you need to do it in separate batches

create table test(id int)
go

alter table Test add id2 int
go
alter table Test ALTER COLUMN id DECIMAL (5, 2) 

you can however add more than 1 column at a time

alter table Test add id3 int, id4 int
go
like image 184
SQLMenace Avatar answered Nov 03 '25 21:11

SQLMenace