Delete Table Index in SQL Server

We have a sample table in our database which has a primary key. Let us check the indexes present in the table. Run the following query to check the index present in the table.

  1. sp_helpindexstudent  
We get the following output once the query is executed.



Let us create another index on a table.
  1. CREATE INDEX In NameON Student(Name)  
Execute the preceding script. Syntax for checking index on a table is given below.
  1. sp_index‘tablename’  
By replacing the tablename with the actual table name it will give us the list of all the indexes present in the table. Let us check the same now. Execute the following script.
  1. sp_helpindexstudent  


We can see that the new index created is present in the above result set. Let us now see how to delete the index we just created.

Syntax for deleting an Index

DROP INDEX <table name>.<index name>

Let us now delete the index that we just created. Execute the following script.
  1. DROP INDEX student.InName  
Execute the query.



Let us run the query again just to verify there is no index present in the table.
  1. sp_helpindexstudent  


As we can see the index created in the table is deleted.

 

Ebook Download
View all
SQL Jobs
Read by 0 people
Download Now!
Learn
View all