alter table then update in single statement
You can't do this exactly in a single statement (or batch) and it seems the tool you are using does not support GO
as a batch delimiter.
You can use EXEC
to run it in a child batch though.
ALTER TABLE A ADD c1 INT, c2 VARCHAR(10);EXEC('UPDATE ASET c1 = 23, c2 = ''ZZXX''; ');
NB: All single quotes in the query need to be doubled up as above to escape them inside a string literal.
Or alternatively you could achieve similar results in a single statement with the aid of some default constraints.
ALTER TABLE A ADD c1 INT NULL CONSTRAINT DF_A_c1 DEFAULT 23 WITH VALUES, c2 VARCHAR(10) CONSTRAINT DF_A_c2 NULL DEFAULT 'ZZXX' WITH VALUES;
But this is not exactly the same as the original query as the default constraints will be left behind and may need to be dropped.
Try this
ALTER TABLE A ADD c1 int,c2 varchar(10)GOUPDATE A set c1 = 23, c2 = 'ZZXX'GO