Using cursor in OLTP databases (SQL server)

假装没事ソ 提交于 2019-12-11 09:37:07

问题


Is it safe to use cursors in stored procs that are called from a website? There is the obvious performance hit, but what I am trying to raise here is the issue with the variable @@Fetch_status. The scope of @@Fetch_status used in stored proc, is a connection. Isn't it possible that two different users call the same stored proc, from the same connection, thru the UI? Wouldn't that cause unexpected results?

In other words, would the fact that @@Fetch_status is global not just to a scope but to the entire connection, cause any concerns?

NOTE: This post is not about whether using a cursor is a good idea. I'd appreciate responses relevant to @@Fetch_status. Please come here to discuss the pros and cons of cursors


回答1:


Unless you are using global cursors you should be safe

that said, why are you using cursors, almost everything can be accomplished set based in sql server and it will be many times faster in almost every situation



来源:https://stackoverflow.com/questions/9316550/using-cursor-in-oltp-databases-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!