Click here to monitor SSC

Tony Davis

Simple-Talk Editor
News, views and good brews

SQL Server's Big Red Buttons

Published Friday, January 06, 2012 12:24 PM

One of the most reassuring aspects of watching a vintage James Bond film is the comfort of knowing that, just when there seems no further hope that the villain's plans for world domination will be thwarted, Bond will glance up at the wall and notice a big red button. Instantly, he knows that all he has to do is press it and the villain's lair will self-destruct messily, with plenty of pyrotechnics, and armed men being tossed into the air like rag dolls.

Of course, you have to wonder why the technologists who built the lair put that big red button on the wall. It seems to be an irresistible urge, and one to which the creators of SQL Server are not immune, as @SQLPoolBoy noted last week in one of his tweets...

        "Looking at a database that has 99% fragmentation across the board. The cause, AutoShrink"

...a database brought to its knees by some poor soul who had accidentally hit one of SQL Server's big red buttons.

You have to feel sorry for anyone who accidentally accepts the default database sizing and auto-growth settings, or turns on AutoShrink, or accidentally creates a collation conflict, or falls foul of any other of a host of 'Red Button' actions that can eventually lead to metaphorical pyrotechnics and DBAs being tossed in the air like dolls.

SQL Server makes it very easy to tweak its various database- and server-level settings and so it's easy for inconsistency to creep in between database and servers, and it's easy for someone to unwittingly hit one of the red buttons. However, for the DBA managing tens of servers, it's not necessarily easy to find out which buttons have been pressed where, or to find best practice advice on how some of these settings really should be configured for each environment.

However, help in various forms is slowly emerging. Brent Ozar has made publicly available his SQL Server Blitz script, which helps you verify some of the absolute fundamentals (Are backups being taken? Are DBCC checks being run?), and then seeks out a few of the more common red buttons, which may need deactivating.

Then there is also SQLCop, a free community tool for "detecting common problems with database configurations and TSQL code". Named after a similar .NET tool (FxCop), it's broader in scope than the Blitz script, checking everything from configuration settings, to fragmented indexes, to missing Foreign Keys, to "code smells" in stored procedures. Red Gate has done some work with the makers of this tool, in incorporating some of their tests into the SQLTest tool, the idea being that the final step to resolving such problems may be automated testing.

However, there is still much work to be done. What are your favorite "Red Button" actions in SQL Server? What is the best way to find and deactivate them before they cause havoc in your Server and databases?

Cheers,

Tony.

Comments

 

GilaMonster said:

The maintenance plan wizard. It's there to maintain the database, so a novice will likely go in thinking that all of the options are required to properly maintain a database. Take all of the options with their defaults (and the obvious selections where necessary) and (on SQL 2008) you get, in order:

CheckDB (fine)
Shrink database (um, no please no)
Reorganise indexes (shuffle them all back into the right order after the shrink)
Rebuild indexes (drop all the nicely reorganised indexes and recreate them)
Update Statistics (all stats, even the ones on the indexes we just rebuilt)
Backup database

I could probably come up with a worse order if I tried, but it would be difficult.

Maintenance plans are generally for the less experienced DBA, so the defaults shouldn't come complete with landmines, which they currently do.


January 6, 2012 3:02 PM
 

NULLgarity said:

After reading this editorial, I can't help but think that SharePoint's logo should simply be a giant, red button.
January 9, 2012 2:02 PM
 

SergioE said:

Mr. Davis, as always, read your post expands my knowledge about the sql server mysteries.

Personally I didn't know those big red buttons in sql server, but it's clear to me that a dba must set them very very very carefully, and as always all depends on the target database.

I wish also  thank you for the 2 tools you mentioned, I will check them and see how can it help me with our little 500gb db.

Best regards,
Sergio E.
Mx
January 9, 2012 6:01 PM
 

Ron Dameron said:

Development databases set to FULL Recovery Model have been a big red button in the past for me.  Initially, they were found when a drive ran out of space.  Then, I started using a T-SQL script on DEV servers to search for databases in FULL. Finally, wrote a script in PowerShell that can check multiple servers for the condition.

# find databases in full recovery on DEVELOPMENT servers
#.\get-full

[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | out-null

$start = get-date
write-host "Start: "  $start

$FilePath = "C:\Output"
$OutFile = Join-Path -path $FilePath -childPath ("DEVELOPMENT_DBs_in_FULL_RECOVERY_" + (get-date).toString('yyyyMMdd_hhmmtt') + ".csv")

@(foreach ($svr in get-content "C:\Input\DevServers.txt")
{
$s = New-Object "Microsoft.SqlServer.Management.Smo.Server" $svr
trap {$s; continue } $s.databases | ? {$_.RecoveryModel.ToString() -eq 'Full'} | select parent, name, recoverymodel                            
}
) | export-csv -noType $OutFile

$end = get-date
write-host "End: "  $end
January 9, 2012 7:54 PM
 

TheHappyDBA said:

Amazing article...thanks for the tools.... I will test them in our test environment and they will probably find some red buttons...LOL

Thanks,
January 9, 2012 9:56 PM
 

MatthewMonroe said:

Thanks for letting us know about Sql server Blitz.  I found Brent Ozar's script to be very useful and informative and have run it each of my servers.  

Easy things I found to fix included changing the owner for Sql Server Agent jobs to sa, re-checking check constraints and foreign key relationships, and switching the page verification mode from Torn_Page_Detection to Checksum (default as of Sql Server 2005).  It was also useful for revealing several large tables that did not have a clustered index yet definitely could benefit from one.
January 10, 2012 2:25 AM
 

Sertacy said:

Yes. Good Post!
January 11, 2012 10:33 AM
 

yolandazeng said:

Snapback Hats Sale    http://www.snapbackhatssale.us/ Snapback Hats Online   http://www.snapbackhatssale.us/ New Era Hats Online     http://www.snapbackhatssale.us/ Snapback Hats     http://www.snapbackhatssale.us/ NFL Hats Online    http://www.snapbackhatssale.us/nfl-hats-online-Categories-25
February 16, 2012 8:53 AM
 

handbags said:

good post,help me alot , thanks

but allow me to recomand my website here:
http://www.2lv.us/louis-vuitton-bags-lv-monogram-idylle-c-16_40.html
cheap louis vuitton monogram bags
March 27, 2012 8:57 AM
You need to sign in to comment on this blog
Latest articles
A first look at SQL Server 2012 Availability Group Wait Statistics
 If you are trouble-shooting an AlwaysOn Availability Group topology, a study of the wait statistics... Read more...

SQL Server Prefetch and Query Performance
 Prefetching can make a surprising difference to SQL Server query execution times where there is a high... Read more...

SSIS Basics: Setting Up Your Initial Package
 When working with databases, the use of SQL Server Integration Services (SSIS) is a skill that often... Read more...

Checking Out SQL Backup Pro 7’s New Automatic Backup Verification
 Wouldn't it be great to offload the daily chore of checking the integrity of your production... Read more...

Chuck Lathrope: DBA of the Day
 Chuck Lathrope was a finalist for the Exceptional DBA of the Year award in 2009. We contacted him to... Read more...