Saturday, October 11, 2014

generate script to rebuild index for all tables

we can generate script for rebuild indexes for specific database by using below query



SELECT 'ALTER INDEX ALL ON ' + t.[table_Schema]+'.'+ t.[TABLE_NAME] + ' REBUILD; '
  FROM INFORMATION_SCHEMA.TABLES t
 WHERE t.[TABLE_TYPE] = 'BASE TABLE'
 ORDER BY t.[TABLE_NAME];
after executing query copy output of query result into new window and execute it. 

No comments:

Post a Comment