I got this script from this site and it works fantastic. I would just like to give an update to this script. All credit should go to the person that published this script on this site not me. I would just like to point out a few things. If you want to schedule this as a job once a new databse get created you should include the msdb, model, northwind, pubs, master and tempdb in the script to not be set to dbo or single user otherwise your sql server agent wont start. The databses can not be set to dbo and single at the same time. I made it to only set the database to dbo and to exclude the above mentioned database. PLEASE NOTE THIS IS NOT MY WORK ALL THE CREDIT SHOULD GOT TO GREG LARSEN FOR THIS GREATE SCRIPT.
Harnessing SQL Server Metadata- Disabling and Rebuilding Indexes
When doing bulk data changes it may be beneficial to disable indexes prior to starting the operation. Fortunately, SQL's rich metadata makes this very easy to automate in a robust fashion.
2018-05-18 (first published: 2015-10-19)
4,845 reads