Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
Your profile
Tag cloud
.net asp.net asp.net mvc azure book bug business intelligence c# cloud computing database dates excel functions gemini google gotcha how to howto iis interview kanban linq madison measurement mvc nhibernate nunit performance process improvement programming rhino mocks security silverlight sql sql friday sql server sql server 2000 sql server 2005 sql server 2008 sql server 2008 r2 sqlserver structuremap t-sql tip trick unit testing vb.net vista visual studio 2010 windows 7
Authors
- SQLDenis (269)

- chrissie1 (200)

- onpnt (96)

- George Mastros (35)

- Alex Ullrich (24)

- tarwn (17)

- naomi (9)

- ca8msm (7)

- damber (7)

- thatrickguy (7)

- emtucifor (7)

- chopstik (6)

- More...
Main Categories
Search
Google Ads
Tags: indexing
T-SQL To find Out If An Index Is Clustered Or Non Clustered
I saw this question in in Google Analytics from a Google search that hit our site.
So, how can you determice if an index is clustered or not? There are two ways, you can use either the INDEXPROPERTY function or the sysindexes/sys.sysindexes system table/view
To see how it works we will create a table with one clustered and one non clustered index on it
Here is the code for that
Use INDEXKEY_PROPERTY in SQL Server to determine if columns in indexes are sorted ascending or descending
How can you find out if the columns that are part of the index are sorted descending or ascending in that index? For example when you create the following index
We all know that we should avoid index and table scans like the plague and try to get an index seek all the time.
Okay, what will happen if we fill a table with one million rows that have the same exact value and then create a clustered index on it.
Yes, you can create a clustered index on a non unique column because SQL Server will create a uniquefier on that column to make the index unique.
Create the following table with a clustered index
A lof of time your index will get fragmented over time if you do a lot of updates or inserts and deletes.
We will look at an example by creating a table, fragmenting the heck out of it and then doing a reorganize and rebuild on the index.
First create this table
Take a look at this query.


LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.