避免使用游标 [英] avoid using cursors

查看:76
本文介绍了避免使用游标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想避免在存储过程中使用游标和循环。

请建议使用示例的替代解决方案(如果可能)。


这些问题的任何建议都将受到赞赏。

提前致谢,

TSNegi

Hi All,
I want to avoid using cursors and loops in stored procedures.
Please suggest alternate solutions with example (if possible).

Any suggestion in these regards will be appreciated.
Thanks in advance,
T.S.Negi

推荐答案

以下是一个示例:
http://www.extremeexperts.com/SQL/Ar...SQLResult.aspx


-

HTH,

Vinod Kumar

MCSE,DBA,MCAD,MCSD
http://www.extremeexperts.com

SQL Server SP3联机丛书
http://www.microsoft.com/sql/techinf...2000/books.asp


" TSNegi" < TI ******** @ mind-infotech.com>在留言中写道

新闻:a1 ************************** @ posting.google.c om ...
Here is a sample:
http://www.extremeexperts.com/SQL/Ar...SQLResult.aspx

--
HTH,
Vinod Kumar
MCSE, DBA, MCAD, MCSD
http://www.extremeexperts.com

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

"T.S.Negi" <ti********@mind-infotech.com> wrote in message
news:a1**************************@posting.google.c om...
大家好,
我想避免在存储过程中使用游标和循环。
请建议使用示例的替代解决方案(如果可能的话)。

任何有关这些问题的建议都将受到赞赏。

提前致谢,
TSNegi
Hi All,
I want to avoid using cursors and loops in stored procedures.
Please suggest alternate solutions with example (if possible).

Any suggestion in these regards will be appreciated.
Thanks in advance,
T.S.Negi



循环和游标是只是编程构造,而不是实际的问题

要解决,所以没有通用的解决方案或示例来说明如何使用
来避免它们。您应该尝试避免或最小化SQL中循环和

游标的使用,这是通过编写基于标准集的代码来完成的:

SELECT,UPDATE,DELETE和INSERT对一组

行而不是一次运行一行的语句。实际细节将取决于

您想要实现的目标。


如果您需要hlep有特定问题,请发布更多

详细信息如下所述:
http:// www.aspfaq.com/etiquette.asp?id=5006


-

David Portas

SQL服务器MVP

-

Loops and cursors are just programming constructs, not actual problems
to be solved, so there is no generic solution or example to show how to
avoid them. You should try to avoid or minimize the use of loops and
cursors in SQL and this is done by writing standard set-based code:
SELECT, UPDATE, DELETE and INSERT statements that operate on sets of
rows rather than one row at a time. The actual details will depend on
exactly what you want to achieve.

If you require hlep with a specific problem then please post more
details as described in:
http://www.aspfaq.com/etiquette.asp?id=5006

--
David Portas
SQL Server MVP
--


不幸的是,那篇文章中的所有例子都是循环!


-

David Portas

SQL Server MVP

-

Unfortunately, all the examples in that article are loops!

--
David Portas
SQL Server MVP
--


这篇关于避免使用游标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆