游标新手 [英] new to cursors

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

问题描述

有人能指出我在MSSQL中学习游标的好资源吗?


谢谢


Dave

Can anyone point me to a good resource for learning cursors in MSSQL?

Thanks

Dave

推荐答案

戴夫,

尝试 www.TechnicalVideos.net 。触发器和存储的视频

程序将对您有所帮助。还有一个专门用光标处理

的视频。


希望这会有所帮助,

Chuck Conover
www.TechnicalVideos.net

" Dave Anderson" <一个****** @ cvn.net>在消息中写道

新闻:EL ************** @ newsread1.news.pas.earthlink .net ...
Dave,
Try www.TechnicalVideos.net. The videos on triggers and Stored
Procedures will help you a lot. There is also a video specifically dealing
with cursors.

Hope this helps,
Chuck Conover
www.TechnicalVideos.net
"Dave Anderson" <an******@cvn.net> wrote in message
news:EL**************@newsread1.news.pas.earthlink .net...
可以有人指出我在MSSQL中学习游标的好资源吗?

Dave
Can anyone point me to a good resource for learning cursors in MSSQL?

Thanks

Dave


请记住,您通常应该尽量避免使用游标。他们

通常不是解决SQL问题的好方法,因为与基于集合的替代方案相比,他们的性能和资源限制相同。

我的观点是大多数游标属于以下三种类别之一:

程序性管理任务(合理使用游标);由

程序程序员写的,他们不懂SQL;用于处理不良数据

设计(例如表中缺少键)。还有其他一些案例,但是他们很少

,在我的经验中很远。


-

David Portas
SQL Server MVP

-
Remember that you should generally try to avoid using cursors at all. They
are not usually a good solution to a problem in SQL because of their
performance and resource constraints compared to the set-based alternatives.

My view is that the majority of cursors fall into one of three categories:
Procedural administrative tasks (a reasonable use of a cursor); Written by
procedural programmers who don''t know SQL; Used to work around a poor data
design (e.g. lack of keys in tables). There are other cases but they are few
and far between in my experience.

--
David Portas
SQL Server MVP
--


David,

我不是完全不同意,但我会对你的意见感兴趣。

通常我使用游标从外部源加载数据。既然你不能控制外部数据的外观,我会做以下事情:


- 将数据加载到临时表中
- 光标通过临时表,验证数据类型并通常按摩

数据,如果需要

- 如果是,请插入我们的生产表中数据通过检查(在光标中完成




我不确定你是否认为这是一项管理任务。我认为使用基于集合的

结构进行的一些

数据检查很难或不可能。


感谢您的观点。

祝您好运,

Chuck


" David Portas" < RE **************************** @ acm.org>在消息中写道

新闻:Jb ******************** @ giganews.com ...
David,
I''m not disagreeing exactly, but I would be interested in your opinion.
Typically I use cursors to load data from an outside source. Since you
can''t control what that outside data looks like, I will do the following:

- load data into a temp table
- cursor thru the temp table, verifying data types and generally massaging
the data, if needed
- insert into our production table(s) if the data passes examination (done
in the cursor)

I''m not certain if you''d consider this an administrative task. Some of the
data checking we do would be hard or impossible to do using a set-based
structure, I think.

Appreciate your views.
Best regards,
Chuck

"David Portas" <RE****************************@acm.org> wrote in message
news:Jb********************@giganews.com...
记住你通常应该尽量避免使用游标。对于SQL中的问题,它们通常不是一个很好的解决方案,因为与基于集合的
替代方案相比,它们的性能和资源限制。
我的观点是,大多数游标分为三类:
程序管理任务(合理使用游标);由不懂SQL的程序程序员编写;用于解决可怜的数据设计(例如表中缺少键)。还有其他一些案例,但根据我的经验,它们只有几美元,而且很远。

-
David Portas
SQL Server MVP
-
Remember that you should generally try to avoid using cursors at all. They
are not usually a good solution to a problem in SQL because of their
performance and resource constraints compared to the set-based alternatives.
My view is that the majority of cursors fall into one of three categories:
Procedural administrative tasks (a reasonable use of a cursor); Written by
procedural programmers who don''t know SQL; Used to work around a poor data
design (e.g. lack of keys in tables). There are other cases but they are few and far between in my experience.

--
David Portas
SQL Server MVP
--



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

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