Tracy McKibben was trudging through code on the hunt for a bug and came across today's example. I was staring at it for a little bit and it got me thinking ... it's time for a new challenge! Think back to the Spot The WTF that I post every once in a while.

Today's challenge is called Fix The WTF and is best enjoyed if you've never programmed anything in T-SQL in your life before. The goal is pretty simple: write T-SQL code to increment a numeric value stored in a CHAR(2) string and see how much faster you can do it than the original "senior programmer" who wrote today's code. Assuming he was a pretty fast copy/paster, I'd say he took two minutes. Allright ... you ready ... set ... go!

	IF @sequenceCode = '01'
		SET @sequenceCode = '02'
	ELSE IF @sequenceCode = '02'
		SET @sequenceCode = '03'
	ELSE IF @sequenceCode = '03'
		SET @sequenceCode = '04'
	ELSE IF @sequenceCode = '04'
		SET @sequenceCode = '05'
	ELSE IF @sequenceCode = '05'
		SET @sequenceCode = '06'
	ELSE IF @sequenceCode = '06'
		SET @sequenceCode = '07'
	-- snip --
	ELSE IF @sequenceCode = '94'
		SET @sequenceCode = '95'
	ELSE IF @sequenceCode = '95'
		SET @sequenceCode = '96'
	ELSE IF @sequenceCode = '96'
		SET @sequenceCode = '97'
	ELSE IF @sequenceCode = '97'
		SET @sequenceCode = '98'
	ELSE IF @sequenceCode = '98'
		SET @sequenceCode = '99'
	ELSE IF @sequenceCode = '99'
		SET @sequenceCode = '00'
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!