The Daily Parker

Politics, Weather, Photography, and the Dog

The dangers of cut-and-paste coding

Last night, while studying for an economics exam, I took a moment to execute the following SQL against a client's production database:

UPDATE table_name
SET column_a = 'Equipment', column_b = 'Equipment'
WHERE column_a = 'Boojums'
GO

UPDATE table_name
SET column_a = 'Borfins', column_b = 'Equipment'
WHERE column_a = 'Nerfherders'
GO

The client called this morning to ask why the application suddenly had two different types of equipment, one which looked suspiciously like a collection of borfins.

You can see what I did, of course. I copied the first statement and forgot to change the copy's second argument. And I quite deservedly looked stupid.

What makes this even funnier: I executed the statement against a staging server first, carefully (I thought) checked the results, and then executed it against the production server. This is why having someone else do quality assurance is a good thing for most programmers.

Comments are closed