Open In App
Related Articles

SQL Query to Add an Agent Parameter in a Database

Improve Article
Save Article
Like Article

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:


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.


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:


Step 7: Viewing the inserted data

SELECT * FROM sales_report;

Last Updated : 19 May, 2021
Like Article
Save Article
Similar Reads
Related Tutorials