SQL Server Backup, Integrity Check, and Index and Statistics Maintenance

Sehr gute Skripte sind bei  Ola Hallengren zu finden:

https://ola.hallengren.com/

Extern lässt sich dies z.B. auf einem SQL Express ohne Agent per Batch aufrufen

sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d master -Q "EXECUTE [dbo].[IndexOptimize] @Databases = 'NAME',@FragmentationLow = NULL,
 @FragmentationMedium = 'INDEX_REORGANIZE,INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
 @FragmentationHigh = 'INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
 @FragmentationLevel1 = 5,
 @FragmentationLevel2 = 30,
 @UpdateStatistics = 'ALL',
 @OnlyModifiedStatistics = 'Y', @LogToTable = 'Y'" -b

Author: Stefan