For each user database remove all the freespace and truncate the transaction log. The script will use the system catalog to produce a list of databases. If you want to excluce a database add the excluded db name to the 'not in' list below.
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,846 reads