Great article - though I did find myself wading through the rather large example. Have written this much smaller example to demonstrate the principle without deep diving into the scenario...
I've often used a useful stored procedure for this type of thing, also works like a charm! Feel free to check it out at http://vyaskn.tripod.com/code.htm direct links to...