18 January 2011

The Abaculator

I enjoy using Red-Gate products.  Really.  I even suspect that the SQL Prompt code-completion product reduces the time it takes me to write SQL.

I enjoyed their recent add likening Hand Coding your SQL to an Abacus, while SQL Prompt was likened to a Calculator:
 

Think how much more efficient you could be with this product!  We can even get supporting evidence from the inter-webs showing just how slow the Abacus really is when compared to our electron chomping marvel:

Oops!  I had a feeling that the abacus would turn out to be pretty fast, but three times faster?  And that's just a virtual abacus - think of the power and air conditioning costs this 9 year old mathematician will save.

Now I'm slightly embarrassed to be a SQL Prompt user.

Red-Gate might want to take a lesson from MathSecret on this one.

13 January 2011

Hacking The Doctor's Credentials

Brent Ozar just published his Microsoft Certified Master certificate along with a call for enhancements.

I never excelled at Photoshop Tennis, but thought I'd take a stab at it using Microsoft's recent jab at VMWare as a starting point.


Of course, Brent's breadth and depth of SQL and IT experience, along with his presentation and writing skills, do a SQL master make.

Congratulations on the MCM!

10 January 2011

Lies, Damned Lies, and Resolutions

Thank you to Microsoft MVP and rampant blogger, tweeter, and silver-screen maven Jen McCown for hosting this month's T-SQL Tuesday (#14).  Congratulations, Jen! (Yes, I'm a fan of the Midnight DBAs)

Many people claim they don't make new year resolutions.  A few of them are telling the truth.  The rest have secret resolutions they won't disclose for fear of failing publicly.  I fall in the latter category.

With this in mind, I have not resolved to get a SQL Server Certification: I have pre-purchased an Exam 4-Pack to cover a double MCITP and am sitting the MCTS: SQL Server 2008, Database Developer today.

I have also not resolved to participate in a T-SQL Tuesday:  I am writing and submitting my first post right now. Insecure?  Yep.  Letting it trip me up?  Not this time.

These things started off as secret professional resolutions, but I've decided to take action on them.

I still have other secret resolutions, mainly recycled secret failures from years past.  Will I be acting on them?  Some yes, and some no.  Will I put them out there as "resolutions" and risk the public failure?  I guess so.
  • That 100 extra pounds (45 Kg / 7 stone) I've acquired since settling down?  Nope.  Not going to resolve it.  I am, however, "resolving" to spend some quality time with the exercise bike so I can manage the stairs better and let the weight take care of itself.  You have my permission to call me on it in a couple months.
  • Replace the broken dishwasher?  Nope.  I'm going to hire somebody who's good at it to do it for me.  I make my living specializing in SQL Server and don't expect my clients to be especially brilliant with database systems.  Why should I expect to hack together a home repair that's anything but mediocre?  A quick note here: my house of full of mediocre but largely functional do-it-yourself jobs, so letting this go is a bit of a challenge for me.
  • Speak at the local SQL Server User Group?  If they'll have me again.
So, nothing spectacular, just a few public steps out of the comfort zone.  Won't you join me?

You can't afford what?

Tibor Nagy recently did a nice intro to Populating a SQL Server Test Database with Random Data.

It was a good primer to generating gobs of data, but part of the problem the solution was addressing wasn't technical: "I heard about some excellent commercial tools but they are expensive and my company cannot afford them."  The first commercial tool that comes to mind is Red Gate's SQL Data Generator, which isn't expensive by any measure, least of all a DBAs time.

It sickens me when a company can afford to squander days of a $50/hour DBA's time hand rolling something that could be had commercially for only a few hundred dollars.  How can a company that can afford a DBA not afford a simple tool that will save days of effort and free up that expensive human time so it can be spent solving business problems?

To illustrate, a company where I used to work had an extravagantly expensive suite of database design, monitoring, and migration tools.  That was well and good, but the migration tool took hours to compare a simple database, and often didn't succeed (though you still had to wait hours to find out).  The result was a lot of squandered time and production releases that were often missing database objects or permissions.  Ouch!

This company frowned on any suggestion to evaluate a different tool-set, so one of the DBAs, who believed more in getting things done than toeing the line (this gave him a reputation as a something of a cowboy), downloaded a trial copy of Red Gate SQL-Compare and started playing with it.  This DBA's compare times went from hours to minutes (or less) and he no longer had last minute manual compare frenzies prior to production releases.

After a few more DBAs started using the evaluation - the tool completely paid for its purchase price in the first week of evaluation - the company finally realized that all this "free" salary time was being squandered, and decided to make the purchase.  The enterprise-class database tool was put to rest, along with its rather generous annual maintenance fees, and they never looked back.

Though I have yet to work there, someday I will work at or run a shop where each DBA has his or her own annual tools budget equal to roughly a single day's pay that can be used to purchase simple tools about which they are passionate.  They gain experience managing a corporate budgetary item and get the power and confidence to use that money to save even more money without any corporate red-tape, thank you very much.

15 November 2010

Nearly Competent

I thought this was a pretty good insight from Jeff Atwood over at CodingHorror…
You can tell a competent software developer from an incompetent one with a single interview question:
What's the worst code you've seen recently?
If their answer isn't immediately and without any hesitation these two words:
My own.
Then you should end the interview immediately. Sorry, pal.

I love the brutal efficiency of the question, and find it to be revealing in the same way as the “on a scale of 1 – 10, how would you rate yourself” question.  This question isn't quite as efficient -- there are more than two answers -- but any answer that isn't actually between 1 and 10 should end the interview.  If the applicant doesn’t realize that 15 is not less than 10, what can you possibly hope to salvage by continuing?

Yes. I’ve heard, with my own ears, somebody seriously rate themselves higher than 10 out of 10.  I'll never forget the claim: "On a scale of 1 to 10, I'm a 13.  My SQL Server skills are that good."  Of course the candidate was hired (it wouldn't be much of a story otherwise) and the consequences weren't pretty.  Years later, the team that made the hire is still trying to overcome the reputation of minimal competence, unresponsiveness, and outright contempt that this individual bequeathed them.

On a lighter note, a little tidbit about the most overlooked risk in software engineering (again, from CodingHorror):
Q: What is the most often-overlooked risk in software “engineering”?
A: Incompetent programmers.

My name is “Bob” and I’m a developer. Now let’s begin planning around my incompetence.

11 November 2010

Restore Me, Please

Our shop has a stored procedure to restore databases that takes care of all the ugly details of file moves and the like.  You supply a target_database_name and a backup_file and it does the rest.  No worrying about which paths to move your data and log files to on each server.  It's even supposed to distinguish between native and Red-Gate backups and do the appropriate magic.


A couple years ago, we had a rock-star DBA "optimize" the restore procedure, and it has only worked intermittently ever since.  We've all taken to using the native backup syntax so we don't depend on "the procedure."  However, we occasionally get a compressed database we need to restore (.sqb), and I recently ran through a painful restore that I thought I'd share to give a quick overview of restoring backups that have been compressed with Red-Gate SQL Backup.

After making a good-faith effort to restore with "the procedure," I grabbed version 6.4 of the Red-Gate SQB Converter so I could extract the .SQB file into its constituent .BAK files.  Not entirely related, but we tend to have 15 .BAK files wrapped up in each .SQB file.  It helps backup performance, but can be a killer on MemToLeave Virtual Address Space (VAS) on 32-bit servers.

In this particular case, it wouldn’t convert the file because it wanted a password.  This is often an indication that the converter version is older than the SQL backup version that created the .sqb file, but I'm sure it could have other meanings, too (like needing a password?).

Since I couldn't get my .bak files out of the .sqb file, I had to crack open "the procedure" and scarf its Red-Gate syntax to do the restore.  Other than the additional Red-Gate syntax, the process is the same we would use with native tools…

1.       Restore filelistonly to get your logical filenames
2.       Determine the location to place your .mdf and .ldf files on the server
3.       Restore your database with move

Here is the relevant syntax…

1.       Get your logical filenames with this:

EXEC master..sqlbackup N'-SQL "restore filelistonly from disk = ''path_to_your_sqb_file.sqb''"'

2.       Get the default file locations for your server (if you can create a database, you should have permissions to write restored database files there, too):

CREATE DATABASE bob
EXEC bob..sp_helpfile
DROP DATABASE bob

3.  Once you have your logical filenames, and the paths to where you want to move them, you can run the restore…

EXEC master..sqlbackup N'-SQL "restore database your_database from disk = ''path_to_your_sqb_file.sqb'' with move ''data_file'' to ''path_to_mdf_file.mdf'', move ''log_file'' to ''path_to_your_log_file.ldf''"'

I'm still a big fan of Red-Gate SQL Backup, I just don't listen to rock any more.

08 November 2010

The Patching Treadmill

Well, it's almost Patch Tuesday again.  Are you ready to apply and test them?  It's one of the most important things you can do to maintain the security and availability of your SQL Servers.  Remember Slammer?  The patch for that was months old, but hadn't been widely applied.

Keeping up with patches used to be a time consuming, hit-and-miss sort of affair.  By scheduling a regular monthly patch release, Microsoft has provided the predictability that many organizations need to manage and keep up with the patching process.  There isn't really an excuse any more for not having some sort of regularly scheduled patch deployment and testing process.

We happen to use Windows Server Update Services (WSUS) to authorize and deploy patches in our environment.  We push the patches through QA and test environments before pushing them to pilot groups then the rest of the enterprise.  It's a pretty decent system and has served us well.

Testing the patches is critical, because they do occasionally cause production outages of their own.  We had to back one out of production a couple of months ago because it affected the communication between one of our Windows applications and its WCF service.  Of course, since we're not perfect, the same patch made it back into test last month, but we were able to get it backed out before it made it through to production again (it had been mistakenly re-authorized in WSUS).  We'll have to really watch out this month: the only thing more embarrassing than getting caught by the same mistake twice is getting caught by it three times.  Three strikes, and you're out, right?

Just to help get things rolling, this is the schedule we use for applying Microsoft's monthly patches. Just place the Microsoft release on the second Tuesday then testing and production rollouts fall right in place.






This is based on an Excel Template by Vertex42