Pages

Showing posts with label Bad SQL. Show all posts
Showing posts with label Bad SQL. Show all posts

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)

Monday, 26 November 2012

Bad SQL, Naughty SQL!

 

During my time as a dev, I’ve done some bad things in SQL, some terrible things that still give me nightmares. 

But I feel like a bit of therapy and I should share, and perhaps you would like to share too?

Bad SQL 1:

I think I used it on a dev system that ran out of space.

   1:  EXECUTE sp_MSforeachtable "ALTER TABLE ? REBUILD WITH (DATA_COMPRESSION = page)";  

 

Feel free to share your BAD SQL, please post anonymously if you are too ashamed. Smile