• [font="Verdana"]Here's a modified form that will work with SQL Server 2005.

    Note that I have not reviewed the code other than to change the issue of assignment during variable declaration (a SQL Server 2008 feature.)

    [/font]