This is extremely off-topic, as you may understand - better if you had to transfer your T-SQL knowledge over to Perl. Anyway, terce's efforts in answering would have been wasted without approval of your node, but please be more Perl-specific in the future.