How do I change 2 or more columns at the same time in Sql Server 2014? (ALTER TABLE / ALTER COLUMN)

2

How do I change 3 columns at the same time in the SQL SERVER table?

I want to change COLLATION , but could be something else.

I tried:

ALTER TABLE dbo.SIX_POSTO
ALTER COLUMN VIS_DS VARCHAR(200) COLLATE Latin1_General_CI_AI NOT NULL,
ALTER COLUMN VIS_DS_OBSERVACAO VARCHAR(200) COLLATE Latin1_General_CI_AI 
NULL,
ALTER COLUMN VIS_DS_ENDERECO VARCHAR(500) COLLATE Latin1_General_CI_AI 
NULL

I've also tried:

ALTER TABLE dbo.SIX_POSTO
ALTER COLUMN VIS_DS VARCHAR(200) COLLATE Latin1_General_CI_AI NOT NULL,
COLUMN VIS_DS_OBSERVACAO VARCHAR(200) COLLATE Latin1_General_CI_AI NULL,
COLUMN VIS_DS_ENDERECO VARCHAR(500) COLLATE Latin1_General_CI_AI NULL

And also:

ALTER TABLE dbo.SIX_POSTO
ALTER COLUMN VIS_DS VARCHAR(200) COLLATE Latin1_General_CI_AI NOT NULL,
VIS_DS_OBSERVACAO VARCHAR(200) COLLATE Latin1_General_CI_AI NULL,
VIS_DS_ENDERECO VARCHAR(500) COLLATE Latin1_General_CI_AI NULL

But it only works like this:

ALTER TABLE dbo.SIX_POSTO
ALTER COLUMN VIS_DS VARCHAR(200) COLLATE Latin1_General_CI_AI NOT NULL
ALTER TABLE dbo.SIX_POSTO 
ALTER COLUMN VIS_DS_OBSERVACAO VARCHAR(200) COLLATE Latin1_General_CI_AI 
NULL
ALTER TABLE dbo.SIX_POSTO 
ALTER COLUMN VIS_DS_ENDERECO VARCHAR(500) COLLATE Latin1_General_CI_AI 
NULL

For each ALTER TABLE there can only be one ALTER COLUMN ?

    
asked by anonymous 04.01.2019 / 21:54

1 answer

3

You can do more than one command to add ADD or remove DROP COLUMN , but you can not ALTER COLUMN . The ALTER TABLE command does not allow you to make more than ALTER COLUMN , that is, you need to ALTER TABLE for each column change that needs to be made.

    
04.01.2019 / 22:42