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]