- Explore
- Collaborate
- Visualize
- Connect
- Pricing
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;
Real-time SQL collaboration is here
Get started with PopSQL and SQL Server in minutes
Previous
Real-time SQL collaboration is here
Get started with PopSQL and SQL Server in minutes