SQL Server basic command

This is a handy list of basic commands;

Append a new column to table

ALTER TABLE table_name
ADD column_name data_type column_constraint;

Append multiple columns to a table

ALTER TABLE table_name
ADD 
    column_name_1 data_type_1 column_constraint_1,
    column_name_2 data_type_2 column_constraint_2,
    ...,
    column_name_n data_type_n column_constraint_n;

Create a new table

CREATE TABLE table_name (
    colulmn_name data_type_1 IDENTITY PRIMARY KEY,
    colulmn_name data_type_2 NOT NULL,
    column_name data_type_3  NULL
);

FavoriteLoadingAdd to favorites
Spread the love

Author: Shahzad Khan

Software developer / Architect