Script Index Recovery

I am looking for help to modify the following script, or at least to properly rebuild the indexes in a table in my database called SearchTable. I am completely new to SQL and I do not want to destroy anything.

SELECT 'ALTER INDEX ALL ON ' + MyDatabaseName.[SearchTable] + ' REBUILD; '
  FROM INFORMATION_SCHEMA.TABLES t
 WHERE t.[TABLE_TYPE] = 'BASE TABLE'
+4
source share
1 answer

The easiest and safest way is to create Maintenance Plan.

Expand Management in Object Explorer> Right-click Maintenance Plans> Maintenance Wizard> Create Index Recovery Plan.

Must be straight. As a result, it executes the task in your server agent, and then you can set the schedule or run the task manually by running this script

EXEC msdb..sp_start_job N'NAME OF JOB'

Service Plan Wizard

, . /, , . , . , Management Studio . .

, ,

>

+3

Source: https://habr.com/ru/post/1589240/


All Articles