It is quite rare to need to rebuild the indexes on an SQL Server but it does happen. When it does, it is quite easy to rebuild an index using SQL Server Management Studio.
Open up the node for the tables in the database and right click on the Indexes folder and select “Rebuild All”. That presents a window with a list of indexes showing the fragmentation. Click on OK to rebuild all the indexes.
If you need to rebuild all of the indexes in a database with many tables, the following simple script performs the rebuild for each table.
EXEC sp_MSforeachtable 'ALTER INDEX ALL ON ? REINDEX'
If you want to rebuild all the indexes with a custom fill factor then see the script in the following article.