• I would recommend a procedural language and not tsql for a problem such as this. Using tsql to do this would be like trying to use a sledgehammer to screw on a bolt - it's just the wrong tool.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events