如何编写存储过程以传递8个参数 [英] how to write stored procedure to pass 8 parameters

查看:57
本文介绍了如何编写存储过程以传递8个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在存储过程中传递8个参数

我必须检查所有参数是否通过,如果所有参数都通过了或者任何一个值正在通过,或者任何两个,三个,四个,五个,六个和所有通过了,则必须显示结果.

如果所有r为null,我也必须显示总结果

我为此写了存储过程.
它有很多条件,即500个条件

但是执行查询时出现问题,显示错误,就像显示查询有太多行一样.
您必须分手查询


如何为上述问题编写存储过程

We are passing 8 parameters in stored procedure

i have to check all parameters are passing or not and the result has to be display if all parameters passed or if any one value is passing or if any two,three ,four,five ,six and all passing.

if all r null also i have to display the total result

i write the stored procedure for it.
It has many conditions i.e 500 conditions

but the problem has occured while executing the query displays the error like it shows that query has too many lines.
you have to break up the query


how to write stored procedure for above problem

推荐答案

对于参数问题,请在参数中使用默认值.

为了简化条件,您可以根据自己的情况拆分查询.除非您告诉我们查询的全部内容,否则我们将无济于事.
For parameter problems, use default value in parameter.

To simplify the conditions, you can split the query according to the scenario you have. We can''t help more unless you tell us what your query is all about.


知道确切的操作是不可能的,因为我不知道您的情况,但是听起来像您的SQL太复杂了.通常,最简单的操作是将选择子查询提取到视图中,从而将SQL的一部分分解为其他存储过程.您可以做的另一件事是编写一个用户定义的函数,参数检查似乎是最主要的选择.您可以在c#中创建用户定义的函数.我从未真正做到过,但是看起来很简单(著名的最后一句话!),请参见
Knowing what to do precisely is impossible, as I don''t know your situation, but it sounds like your SQL is just too complicated. In general the simplest thing you can do is to extract select subqueries into views break down parts of your SQL into other stored procedures. Another thing you can do is to write a user defined function, the parameter checking seems a prime candidate for this. You can create the user defined functions in c#. I''ve never actually done this, but it seems simple enough (famous last words!), see this blog entry[^] for guidance.

Hopefully other CPians will chip in with other advice, but this is where I''d start


这篇关于如何编写存储过程以传递8个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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