1

Is there are more terse way of writing (SQL server 2008)

alter table newclaims alter column id int not null go alter table newclaims add primary key(id) 

the table is very large and this will have to make two passes over it and I'd like to know if I can change the nullability and add the primary key all in one statement.

1 Answer 1

1

The documentation for alter table suggests that you cannot both alter a column and add a constraint.

ALTER TABLE [ database_name . [ schema_name ] . | schema_name . ] table_name { ALTER COLUMN column_name { ... } | ADD { ... } [ ,...n ] 
Sign up to request clarification or add additional context in comments.

1 Comment

completely unrelated but by you posting that I a light bulb went on for me understanding how to read that documentation. You posting that little snippet there really helped me out on something completely unrelated

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.