【发布时间】:2014-11-26 05:05:03
【问题描述】:
我在程序中遇到了问题。
我必须在过程中使用 if else 检查多个条件,这需要更多时间来执行。
程序结构如下
create procedure sp_CheckMultipleconditions
@Con1 varchar(10) = null,
@con2 int = null,
@con3 int = null,
..
@Con6 varchar(10) = null
as
BEGIN
if(@con1 is not null)
begin
----- statement ----
end
else if(@Con2 is not null)
begin
----- statement ----
end
.
.
.
else if(@Con2 is not null and @Con3 is not null)
begin
.
.
.
end
END
通过这种方式,我编写了具有 36 个 if else 条件的程序,这需要更多时间,有人可以提出更好的方法吗?
谢谢
【问题讨论】:
标签: sql-server if-statement stored-procedures parameters