Created
July 24, 2018 02:03
-
-
Save chrismckelt/a35bca1428a1e7560cdef030ef9862c4 to your computer and use it in GitHub Desktop.
sql shrink databases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
'USE [' + d.name + N']' + CHAR(13) + CHAR(10) | |
+ 'DBCC SHRINKFILE (N''' + mf.name + N''' , 0, TRUNCATEONLY)' | |
+ CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10) | |
FROM | |
sys.master_files mf | |
JOIN sys.databases d | |
ON mf.database_id = d.database_id | |
WHERE d.database_id > 4; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment