• A cursor is horrible horrible thing. You usually try to avoid this in SQL Server and go for a set-based solution.

    This article describes a very performant function to split your strings. It's not an easy article, so take your time reading it.

    Tally OH! An Improved SQL 8K “CSV Splitter” Function[/url]

    This function will knock the socks off the cursor and it will give you an easy way to use it in your queries.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP