posted on Monday, January 16, 2006 7:01 PM by amachanic

My heart swells with pride!

... For I have won Phil Phactor's Impenetrable Code contest!

I am still writing my acceptance speech for the prestigious awards ceremony, but I have to say, it's a great feeling to know that I can write thoroughly unmaintainable SQL.  It's something that I think every developer should aspire to--if they value job security above all else!  In today's economy, you just never know when you'll be let go.  So I say, give yourself that little edge.  Make yourself invaluable the old fashioned way: make it painful to lose you and your "skills".  And even if they do fire you for incompetence, they'll still need to bring you back as a consultant six months down the road when they need to maintain your sad excuse for code.  And that, my friends, is the Good Life in a nutshell.

My winning entry in this fabulous test of coding skill:


SELECT
UPPER(RIGHT(LEFT(@@VERSION,2),1))+SUBSTRING(MiR,1,15%6)+RIGHT(LEFT
(CONVERT(VARCHAR,[c6[[447]),4),1)+CHAR(CAST(STUFF(ZuB,2,0,REPLICATE('0',
1))AS INT))+(SELECT(SUBSTRING(name,3,1))FROM[master]..[sysdatabases]
WHERE(dbid)=(SELECT(MIN(dbid))FROM[master]..[sysdatabases]))+COALESCE(
SUBSTRING([c6[[447],0^1034,((15-10)/5)-1),SPACE(1))+LEFT(SPACE(1)+RIGHT(
[rD9 005],LEN([rD9 005])-(ASCII('9')-ASCII('0'))),2)+SUBSTRING([556 X10.]
,2,1)+RIGHT(REVERSE(rNNNNNNoPZZ),1)+SUBSTRING([rD9 005],7,1)+[64]+CHAR
(ASCII(RIGHT(REVERSE(MiR),1))-14)+RIGHT(MiR,1)+CHAR(ASCII(LEFT(MiR,1))
-(ASCII(LEFT(REVERSE(MiR),1))-ASCII(LEFT(MiR,1))))+CHAR(ASCII(LEFT(
(SELECT(SUBSTRING(REVERSE(rNNNNNNoPZZ),3,2))x00R),1))-4)+RIGHT(LEFT
([c6[[447],6),2)+RIGHT([556 X10.],1)+('?')FROM(SELECT(STUFF(SUBSTRING(
DB_NAME(1),3,2),2,0,CHAR(32))),CONVERT(VARCHAR,low+high-1)FROM[master]
..[spt_values][xR234]WHERE((xR234.type)='P')AND(xR234.number)=105)
[x4401C6](MiR,ZuB),(SELECT TOP 1(0x72723668626C6C4D78785A3437),name,
(TYPE_NAME)FROM[master]..sysobjects,master..[spt_datatype_info]WHERE
CONVERT(varbinary,name)=(0x730070005F004D00530072006500740072006900)
+(0X6500760065005F007000)AND(ss_dtype)=(34)ORDER BY(id))[889R U]([c6[[447],
[rD9 005],[556 X10.]),(SELECT(MIN(SUBSTRING(name,6,5))), MAX(RIGHT(name,
1))FROM[master]..[syscolumns]WHERE(name)=CONVERT(varchar,0x646174615F707265636973696F6E
))MxxxxxB01(rNNNNNNoPZZ,[64]) 


... Quality is job #1!

Comments

# Talk about unreadable! @ Monday, January 16, 2006 8:02 PM

Adam quite rightly picks up the prize in Phil Phactor's Impenetrable Code contest!
His mind boggling...

Anonymous

# Talk about unreadable! @ Monday, January 16, 2006 8:02 PM

Adam quite rightly picks up the prize in Phil Phactor's Impenetrable Code contest!
His mind boggling...

Anonymous

# re: My heart swells with pride! @ Monday, January 16, 2006 10:26 PM

Sweet! Congratulations! And that is truly horrible code. You should be proud :)

Bill Graziano

# re: My heart swells with pride! @ Tuesday, January 17, 2006 6:05 AM

Congrats Adam. Nice script

Madhivanan

# re: My heart swells with pride! @ Tuesday, January 17, 2006 2:01 PM

I am impressed. While I have seen some bazaar legacy, yours is truely a work of art. I have been looking at it ( reformatting) to understand how it works. I have even learned something new. Who knew that you could specify a column alias after the derived table was named.

Scott F

# re: My heart swells with pride! @ Friday, January 20, 2006 5:30 AM

Yes, it was a magnificent achievement. I have not seen its like since, years ago, I had to take over the code of a Sybase contractor who had just asked for his rate to be doubled and was subsequently shown the door. It was an easy decision by the Judges at Red-Gate Software.

Phil Factor

# re: My heart swells with pride! @ Monday, January 23, 2006 10:32 AM

Truely... well... astounding.

znichter

# re: My heart swells with pride! @ Tuesday, January 31, 2006 6:57 PM

That is truely hideous - I stand in awe!

You are the String King; next time I have a tricky string manipulation problem I know who to ask. One thing it has made me aware of, however, is that you have far too much time on your hands (maybe you need a few kids to suck up the hours you would otherwise spend on obfuscating SQL code).

Mike Hodgson

# re: My heart swells with pride! @ Friday, February 17, 2006 1:09 AM

Here is a similar
http://www.developmentnow.com/g/113_2004_11_0_0_435358/third-edition-of-SQL-FOR-SMARTIES-in-2005.htm

Vlad

# re: My heart swells with pride! @ Saturday, February 18, 2006 1:26 PM

Where is the SQL Server 2005 version?

Now I have to wait until I get to work and I have a SQL Server 2000 Server to connect to see what this produces.. but it truly has the air of evil about it.

Perhaps I will convert it for you today. :)

Well done! Congratulation!

Ward Pond

# re: My heart swells with pride! @ Saturday, February 18, 2006 1:27 PM

Where is the SQL Server 2005 version?

Now I have to wait until I get to work and I have a SQL Server 2000 Server to connect to see what this produces.. but it truly has the air of evil about it.

Perhaps I will convert it for you today. :)

Well done! Congratulations!

Ward Pond

# re: My heart swells with pride! @ Wednesday, March 01, 2006 7:34 PM

Hilarious! Made me think of the classic essay "How to Write Unmaintainable Code" http://mindprod.com/jgloss/unmain.html

Chuck Boyce