How to Add a Column in SQL Server

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;
Cta
Real-time SQL collaboration is here
Get started with PopSQL and SQL Server in minutes