Search code examples
sqlsql-serverindexingclustered-indexnon-clustered-index

Default index in MS SQL Server


When I use the below query to create index for a column in MS SQL Server

create index IX_indexname on tablename(columnname);

without mentioning it as clustered or non clustered index, what index will be created? Which is the default index?


Solution

  • Default would be non clustered.

    You can refer to documentation when in doubt..

    Below is the syntax from MSDN for create index statement

    CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name

    everything in Square brackets is optional,so you would be left with

    create index index_name

    MSDN again says

    If CLUSTERED is not specified, a nonclustered index is created.