Index SQL Server Database

Index SQL Server Database

Index SQL Server 2008R2 Database

Every once in a while it’s a good idea to re-index your tables when you are using Microsoft SQL Server. Unlike MySQL sql server does not automatically re-arrange tables and put them in the proper order they should be, so it’s a manual process that can be scripted.

Open up SQL Server Management Studio

SQL Server 2008 Management Studio Connect to Server with Windows Authentication

go to the database that’s giving you trouble —let’s just call it SUSDB (Windows Update Services Database)

Object Explorer with the SUSDB database expanded to its Tables folder

Expand the tables until you find the table in question in this case we will use tb.EventInstance (synchronizations in WSUS)

dbo.tbEventInstance table expanded showing Columns, Keys, Indexes and Statistics

Expand Indexes, if we want to rebuild the indexes on one field, right click, and hit rebuild

Right-click on the clustered PK index of tbEventInstance with Rebuild highlighted

if we want to rebuild the indexes on ALL fields Right Click Indexes Folder

Right-click on the Indexes folder with Rebuild All highlighted

select Rebuild All

Rebuild Indexes dialog listing tbEventInstance indexes with 62 to 97 percent fragmentation

as you can see, this table is fragmented, and needs to be re-indexed, hit OK

it should quickly go through and fix all indexes

Rebuild Indexes progress with the first indexes rebuilt successfully and fragmentation dropping

That’s it!

 

To get hosted SQL Server visit www.zwiegnet.com/go to get started today

Related guides: Find Database Names Microsoft SQL Server | Fix Microsoft SQL Express Memory Issues

Leave a Reply

Your email address will not be published. Required fields are marked *