---
title: "Indexes in SQL Server"  
description: "In this  Article i am Discuss about Indexes in SQL."  
author: "Niraj Kumar Mishra"  
published: 2017-08-11  
updated: 2017-12-26  
canonical: https://www.mindstick.com/articles/12525/indexes-in-sql-server  
category: "mssql server"  
tags: ["database design"]  
reading_time: 2 minutes  

---

# Indexes in SQL Server

##### Indexes

Indexes are used in [relational databases](https://www.mindstick.com/forum/158002/what-is-nosql-and-how-does-it-differ-from-traditional-relational-databases) to quickly retrieve the data .It is similar toindexes at the front of the books whose purpose is to find a topic quickly. Data is internally stored in a SQL [Server database](https://www.mindstick.com/forum/159667/how-to-migrate-the-sql-server-database-to-a-lower-version) in “pages” where the size of each page is8KB.

##### Type of Indexes

In [SQL Server](https://www.mindstick.com/articles/34/create-table-in-microsoft-sql-server) indexes are one of the following two types:

1. [Clustered Index](https://www.mindstick.com/blog/337/clustered-non-clustered-indexing-in-sql-server)
2. Non-Clustered Index.

##### 1. Clustered Index

Clustered index is the index that will arrange the rows physically in the memory in sorted order.An advantage of a clustered index is that searching for a range of values will be fast.

##### 2. Non- Clustered Index

Unlike a clustered indexed, the leaf nodes of a non-clustered index contain only the values from the indexed columns and row locators that point to the actual data rows, rather than contain the data rows themselves.

##### Creating Index

##### \

```
create index SalaryIN on Emp(Salary) 
```

\
When you are want to take more than one fields on Index then that Index are Called Composite Index

```
create index IdSalaryIN on Emp(Id asc, Salary asc) 
```

##### Unique Index

When an Index is Created By using unique Keyword then that Index is Called [Unique Index](https://www.mindstick.com/forum/159374/transaction-with-multiple-updates-and-unique-index). If you make Unique Index on Salary Column then Salary Column automatically made [Unique Key](https://www.mindstick.com/interview/297/define-primary-and-unique-key) Constraints.

```
create Unique index SalaryIN on Emp(Salary)
```

##### \

##### Deleting indexes

##### \
Like as Droping Table you can also Delete Indexes by using Drop Keyword Like:

```
   drop index <index-name> on <object name>   drop index SalaryIN on Emp
```

##### \
Getting list of indexes

##### If you want to check how many Indexes are available in your Table then you can

##### use a System defined Stored Procedure

##### \sp_helpindex. By using this SP you can get All Index.

##### \
sp_helpindex < Table Name>

##### \
sp_helpindex ‘Emp’

---

Original Source: https://www.mindstick.com/articles/12525/indexes-in-sql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
