SQL Server – Testing Index Fragmentation

sql serversql-server-2008

I am filling my table in my SQL Server database with some data and I have partitions. I have one clustered index in the table. The problem I am facing is that I am not getting any fragmentation which I need in order to test. After reading some articles, I came to conclusion that I need to use file groups, but I am not sure how to achieve that.

Best Answer

If you're trying to artificially induce fragmentation, insert the data "backwards". That is, if your clustering key is an integer column ascending, load the data in descending order by that same integer column. You should get page splits aplenty.