PopSQL

How to Add a Column to SQL Server Table

Adding a column in SQL Server involves using the ALTER TABLE command.

Adding a brand_id smallint column:

alter table products
add brand_id smallint;

Adding a brand_id smallint column with a default value:

alter table products
add brand_id smallint default 1;

Adding a string (varchar) column with a not null constraint:

-- note: this is possible only if the table contains no data!!
alter table products
add description varchar(100) not null;

Adding more columns at the same time:

alter table products
add
  brand_id smallint default 1,
  description varchar(100) not null;
database icon
SQL editing that just rocks
PopSQL and SQL Server, better together