• Dwain posted the exact way I would do it - with Jeff's DelimitedSplit8K.

    However, I noticed that you're using a MAX instead of 8000. When you pass the MAX value to the function, it will only handle 8000 characters. If you change the data type of the function parameter to a MAX instead of 8000, performance is going to tank. It'll still function and perform okay, but it won't be the high-performance function we've all come to know and love.

    I've been pretty far down this road, trying many different scenarios, and the bottom line is that LOBs (the MAX) simply don't like to be joined to. Even if you declare the parameter as a MAX and pass a Varchar(8000) that's less than 8000 in length, it still treats it as a MAX and performance deteriorates. Plus, you have the added bonus of a cast.