To reindex all the indexes in a Microsoft SQL database, follow these steps:

1. On the Start menu, point to Programs, point to Microsoft SQL Server, and then click Query Analyzer.

2. In the Connect to SQL Server dialog box, click OK.

3. On the Query menu, click Change Database.

4. In the Select Database of dialog box, click the Microsoft CRM database that you want to work on, and then click OK.

5. In the Query window, type the following commands:

DECLARE @TableName varchar(255)
DECLARE TableCursor CURSOR FOR
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'base table'
OPEN TableCursor
FETCH NEXT FROM TableCursor INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'Reindexing ' + @TableName
DBCC DBREINDEX(@TableName,' ',90)
FETCH NEXT FROM TableCursor INTO @TableName
END
CLOSE TableCursor
DEALLOCATE TableCursor

6. Click the Execute Query button on the toolbar, and the results will show in the results panel.

Thanks to webdigo