When creating lengthy T-SQL queries, sometimes a set-based approach just doesn’t cut it.
So when you find yourself going with a procedural-based approach and using a Cursor like a foreach loop, be sure to check out the the available attributes for Cursors to boost performance.