In this article, we will learn how we add an extra or a new parameter after a table is created using ALTER command in Microsoft SQL Server in detail step-by-step:
Step 1: Creating database sales by using the following SQL query:
CREATE DATABASE sales;
Step 2: Using the database sales by using the following SQL query:
USE sales;
Step 3: Creating a table sales_report with 4 columns using the following SQL query:
CREATE TABLE sales_report
(
customer_id VARCHAR(20),
customer_name VARCHAR(40),
product_id VARCHAR(20),
order_status VARCHAR(20),
);

Step 4: Viewing the columns in the table using the following query:
SELECT * FROM sales_report;

Step 5: Adding an extra parameter agent:
In Microsoft SQL Server, add an extra parameter using the ALTER command which alters the table by adding an extra column into the table.
Syntax:
ALTER TABLE table_name
ADD parameter datatype;
So, now using ALTER command we will add a new column named as agent in our table(i.e., sales_report)
ALTER TABLE sales_report
ADD agent VARCHAR(40);
Viewing the added column agent after the change :
SELECT * FROM sales_report;

Agent column was added into the table
Step 6: Inserting rows into the sales_report table using the following SQL query:
INSERT INTO sales_report VALUES
('C10002','PRATIK','E1221','DELIVERED','DHRUVA'),
('C10003','DINESH','E1224','PENDING','DHRUVA'),
('C10006','HARSHITH','E1228','DELIVERED','GUPTA'),
('C10007','KARTHIK','E1342','CANCELLED','DHRUVA'),
('C10010','SARTHAK','E1344','PENDING','GUPTA');

Step 7: Viewing the inserted data
SELECT * FROM sales_report;
