Sql-server – Rebuild indexes in a DB except for one table

maintenancesql serversql-server-2008-r2t-sql

I have a table in my database that is constantly monitored by an application server for changes. Unfortunately rebuilding the indexes connected with this table breaks the app server's connection. This causes print jobs and various other processes to fail silently on the application server.

I have created a small monitoring SQL job that lets me know when this happens, but I would prefer to prevent it from happening in the first place.

I need to rebuild indexes weekly for performance reasons, but I would be fine with skipping the indexes associated with that table.

How can I rebuild indexes for the rest of the database without touching that table?

Edit: I am currently using an SSIS job (the canned maintenance plan) to rebuild all indexes for all tables in the DB. After that it updates stats and checks integrity.

Best Answer

You should implement a better solution, such as Michelle Ufford's - it will perform much more intelligent decisions on which indexes to defrag, rebuild or leave alone, and it is very easy to have exclusions:

http://sqlfool.com/2011/06/index-defrag-script-v4-1/