I appreciate you sharing but, be advised, shrinking databases every day is a form of "Death by SQL".
1. It can and usually will cause a type of fragmentation that can absolutely cripple your database for performance. The only way to recover from that is to do the necessary index maintenance and that can cause wanton growth of the MDF file if you use REBUILD or wanton growth of the LDF file if you use REORGANIZE.
2. Except when there has been accidental and incredible growth of either the MDF or LDF files, shrinking the database on a daily basis is totally fruitless unless you find out what is causing the excessive growth. It's a whole lot like washing your clothes and then drying them on a clothesline in the rain with the occasional dog lifting his leg on the basket you also left outside.
3. Shrinking the databases takes valuable time away from more useful and more critical maintenance such as finding stats the need to be updated and then updating them.
is pronounced ree-bar and is a Modenism for R
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair
How to post code problemsHow to post performance problemsForum FAQs