Pages

Tuesday, 27 November 2012

#BADSQL 2

This is my 2nd submission for bad SQL..

Bad SQL 2:
The dev system has run out of disk space.  Lets shrink all the databases, that will free up some space.

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

It might seam like a good idea, but it does apply to EVERY database.
DBCC SHRINKDATABASE ('master' , 0)
DBCC SHRINKDATABASE ('tempdb' , 0)
DBCC SHRINKDATABASE ('model' , 0)
DBCC SHRINKDATABASE ('msdb' , 0)
DBCC SHRINKDATABASE ('ReportServer' , 0)
DBCC SHRINKDATABASE ('ReportServerTempDB' , 0)