存储过程或网络摄像头中的循环?哪个最有效? [英] Loops in stored proc or webcode? Which is most efficient?

查看:72
本文介绍了存储过程或网络摄像头中的循环?哪个最有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为交叉帖子道歉,但这确实是一个双面的问题。


给定在存储过程中创建循环语句的选项

sql server或.net网页的代码隐藏,你会选择
选择和为什么?


我问的原因是我创建了一个网页基本上通过一连串的循环来确定哪个存储过程开始。这是代码隐藏中写的

。在我看来,我可能很容易在主中创建循环。存储过程然后将确定哪个存储过程开始。 IOW,我将从网页传递

处理到sql server。这有什么优点/缺点?


先谢谢我的朋友们。

解决方案

>我问的原因是我创建了一个网页,该网页基本上通过

一连串的循环来确定哪个存储过程开始。这是在代码隐藏中编写的。在我看来,我可能很容易在主中创建循环。存储过程然后确定哪个存储过程开始。 IOW,我会将
处理从网页传递给sql server。这有什么优点/缺点?




而不是性能,我认为这更多的是什么使得
$ b从管理/维护的角度来看,这是一种感觉。使用什么标准

来决定调用哪个存储过程?这些与业务相关吗?b $ b规则,客户输入的数据,数据库中的数据,......?你能展示出一连串的循环的样本吗?你正在运行?


-

请发布DDL,样本数据和所需结果。

参见 http://www.aspfaq.com/5006 获取信息。

< br>

很难说不知道你的代码和你想要实现的目标。


IMO在服务器上调用存储过程是没用的

找出应该调用哪个其他proc。我会做这个客户端。


那说你可能想进一步解释为什么你需要循环找出

哪个存储过程开始。例如,如果你在数据库行上循环到

调用一个特定的程序,这个程序取决于行中的某些东西,我会做

而不是单个存储过程,相应地处理所有行使用if

可能只有一个或几个SQL语句...


Patrice


-


Roy < RO ********** @ gmail.com> écritdansle message de

news:11 ********************** @ z14g2000cwz.googlegr oups.com ...... < blockquote class =post_quotes>为交叉帖子道歉,但这确实是一个双面的问题。

给定在sql server的存储过程中创建循环语句的选项或者在.net网页的代码隐藏中,你会选择哪个以及为什么?

我问的原因是我创建了一个基本上贯穿一个网页的网页。循环以确定要启动哪个存储过程。这是在代码隐藏中编写的。在我看来,我可能很容易在主中创建循环。存储过程然后确定哪个存储过程开始。 IOW,我会将
处理从网页传递给sql server。这有什么优点/缺点?

先谢谢我的朋友。



最好的解决方案是通常是为了避免使用数据循环。 SQL

是一种声明性语言,而不是程序性语言和大多数数据

操作操作具有基于集合的解决方案,不需要

循环。


如果不了解你在做什么,很难推荐。

一般来说,如果你需要访问数据,通常需要付费

通过SP。


-

David Portas

SQL Server MVP
-


Apologies for the cross-post, but this truly is a two-sided question.

Given the option of creating Looping statements within a stored proc of
sql server or in the code-behind of an .net webpage, which would you
choose and why?

Reason I ask is I created a webpage which essentially runs through a
litany of loops to determine which stored proc to kick off. This is
written in the code-behind. It occurred to me that I could probably
just as easily create the loops in a "master" stored proc which would
then determine which stored proc to kick off. IOW, I''d be passing the
processing from the webpage to sql server. What are the
advantages/disadvantages of this?

Thanks in advance my friends.

解决方案

> Reason I ask is I created a webpage which essentially runs through a

litany of loops to determine which stored proc to kick off. This is
written in the code-behind. It occurred to me that I could probably
just as easily create the loops in a "master" stored proc which would
then determine which stored proc to kick off. IOW, I''d be passing the
processing from the webpage to sql server. What are the
advantages/disadvantages of this?



Rather than performance, I think it is much more a question of what makes
sense from a management/maintenance perspective. What are the criteria used
to decide which stored procedure to call? Are these related to business
rules, data the client enters, data in the database, ...? Can you show a
sample of the "litany of loops" you are running?

--
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.


Hard to say without knowing your code and what you try to achieve.

IMO it''s useless to call a stored proc on the server whose job is just to
find out which other proc should be called. I would do this client side.

That said you may want to further explain why you need to loop to find out
which stored proc to kick off. For example if you loop on database rows to
call a particular procedure that depends on something in the row, I would do
instead a single stored proc that process all rows accordingly using if
possible a single or several SQL statements...

Patrice

--

"Roy" <ro**********@gmail.com> a écrit dans le message de
news:11**********************@z14g2000cwz.googlegr oups.com...

Apologies for the cross-post, but this truly is a two-sided question.

Given the option of creating Looping statements within a stored proc of
sql server or in the code-behind of an .net webpage, which would you
choose and why?

Reason I ask is I created a webpage which essentially runs through a
litany of loops to determine which stored proc to kick off. This is
written in the code-behind. It occurred to me that I could probably
just as easily create the loops in a "master" stored proc which would
then determine which stored proc to kick off. IOW, I''d be passing the
processing from the webpage to sql server. What are the
advantages/disadvantages of this?

Thanks in advance my friends.



The best solution is usually to avoid using loops at all with data. SQL
is a declarative language rather than a procedural one and most data
manipulation operations have set-based solutions that don''t require
loops.

Without understanding what you are doing it''s difficult to recommend.
In general if you require access to data it usually pays to do it
through an SP.

--
David Portas
SQL Server MVP
--


这篇关于存储过程或网络摄像头中的循环?哪个最有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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