• Check this article. See if this helps.

    http://www.sqlservercentral.com/scripts/T-SQL/66830/