March 21, 2014 at 8:52 am
Good points, John. I tend to avoid correlated sub-queries as much as possible because there are usually better ways to accomplish the same result. That doesn't mean they're bad - just not always appropriate. Same for cursors - sometimes they have a place because row-by-row processing is the best solution or even the only solution. In this case I used a cursor for convenience of previewing the results and because this is hopefully a one-time or rarely used bit of code. For longer-term uses, I'd definitely recommend saving a script instead of running this sort of code regularly.
I try to make sure others understand why I recommend against certain practices, at least at a basic level. Just saying "don't do this" rarely has the intended effect. It often becomes "don't do this ever" with no understanding about why it was to be avoided in the first place.
March 21, 2014 at 11:14 am
Works with varchar datatype too.
Watch out for when you attempt to output that variable though. If it gets large enough (64K of characters) it'll truncate your output.
I use this approach all the time so it tickled me pink to see you mention it.;-)
Viewing 2 posts - 16 through 16 (of 16 total)
You must be logged in to reply to this topic. Login to reply