Search This Blog

Google Analytics

Tuesday, November 24, 2015

MsSQL: Shrink ALL Databases Using 1 Single Line of SQL Statement

Over time, the database logs on your database server may take up significant amount of disk space especially if there are many databases with lots of transactions. One quick method to free up disk space is to "shrink" your databases. Instead of shrinking one database at a time using the GUI, you can run a single line of SQL statement to do just that.

EXEC sp_MSForEachDB 'DBCC SHRINKDATABASE (''?'' , 0)'

Hope it helps.

No comments:

Post a Comment

Do provide your constructive comment. I appreciate that.

Popular Posts