Jaa


T-SQL coding challenge

This is an oldie, but a goodie.  It's an article by Ken Thompson about, among other things, writing self-replicating programs.  Thompson is one of my heroes and someone who's had a profound impact on the industry.  His list of accomplishments is too long to get into here, but let me summarize it by saying that he was one of the original authors of Unix, invented the B programming language (the precursor to C), UTF-8 encoding, regular expressions, and some of the earliest sophisticated chess programs.  It would be hard to overstate the influence he has had on computer science and computer technology.

Back to the article.  It touches on the educational value of writing a self-replicating program.  I've learned something from this exercise every time I've done it.  So, today's challenge is to do this in T-SQL -- to write a T-SQL script that replicates itself.  Please read Thompson's article before beginning.  Then post back here with your solutions.  I know a lot of you like to email me directly, and that's fine, but if you'll post your answers here, everyone can benefit from them.  I'll commit to perusing through these and posting my comments about your solutions asap.

Comments