gpt4 book ai didi

sql-server - 游标与 while 循环 - 游标的优点/缺点是什么?

转载 作者:行者123 更新时间:2023-12-02 01:27:03 26 4
gpt4 key购买 nike

使用 while 循环代替游标是个好主意吗?

游标的优点/缺点是什么?

最佳答案

我遵循以下建议:

[...] which is better: cursors or WHILE loops? Again, it really depends on your situation. I almost always use a cursor to loop through records when necessary. The cursor format is a little more intuitive for me and, since I just use the constructs to loop through the result set once, it makes sense to use the FAST_FORWARD cursor. Remember that the type of cursor you use will have a huge impact on the performance of your looping construct.

— 蒂姆·查普曼 Comparing cursor vs. WHILE loop performance in SQL Server 2008

链接的文章包含如何实现每种方法的简单示例。

关于sql-server - 游标与 while 循环 - 游标的优点/缺点是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/139843/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com