Unreadable code

Comments 0

Share to social media

Producing unreadable Transact SQL is something of an art form. We all know that the best Transact SQL Style is to make everything elegant and obvious, with explanatory identifiers, liberal comments and deft formatting. It doesn’t always happen, for a number of reasons.

One of the more subtle effects of acute caffein poisoning is to produce manic and ridiculously clever code that, when one later reviews it, makes little or no sense. It cannot be coincidence that it is always such code that one is called back to maintain. The only way to tackle such evil code is to once more sup from the evil brew until the code makes sense and then lunge back in with a manic chuckle and throbbing forehead.

When inpenetrable code is accidental, or a side effect of substance abuse, it can be amusing to anyone not tasked with maintaining it. but to deliberately produce such stuff is …is ..er… the subject of this Blog entry

To celebrate the new year I offer a challenge for the most impenetrable code you can write. It has to execute against Microsoft’s Pubs database. Here is a simple example to ‘prime the pump’.

Select [Select] [select], [from]
[from] from (Select [select].[title] [select] , [from].[pub_name]
[From] from [titles] [select] inner join [publishers] [from]
on [from].[pub_ID]=
   [select].[pub_ID])[from]

 

Load comments

About the author

Phil Factor

See Profile

Phil Factor (real name withheld to protect the guilty), aka Database Mole, has 40 years of experience with database-intensive applications. Despite having once been shouted at by a furious Bill Gates at an exhibition in the early 1980s, he has remained resolutely anonymous throughout his career. See also :

Phil Factor's contributions