SQL: Cursor types in SQL Server
When I’m running SQL Server Advanced T-SQL classes, we spend time discussing cursors. The general message is that most of the time, but not always, cursors are the wrong answer. The problem with cursors is that instead of telling SQL Server what you want it to work out (ie: declarative query), you are telling it how to work that out (ie: procedural query).
You’ll hear people say to never use cursors. This is also incorrect. There are occasions where I do use cursors. Mostly this is when I’m building utilities that do things like scripting objects in the database. I’d almost never use a cursor though, in general data processing running against SQL Server. You don’t want to be doing row by row processing against the server.
2018-12-12