什么是分别使用下拉菜单进行搜索的stoerdproc [英] What is the stoerdproc for search using dropdown separetly

查看:79
本文介绍了什么是分别使用下拉菜单进行搜索的stoerdproc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建存储过程以分别在两个下拉列表中以及同时在两个下拉列表中进行搜索.例如,如果我想使用第一个或第二个下拉列表进行搜索,它必须显示符合第一个或第二个下拉列表的结果,或者如果我想搜索两个下拉菜单必须显示对两个drpdowns的重新编码结果.请帮助这是我的存储过程,它可以工作,但是它允许我使用两个dropdownlits搜索,但是如果我想搜索1 dropdown,则会出现错误.请帮助,如果我想搜索任一下拉列表.

how to create a stored procedure to search in two dropdownlist separatly and also in both. eg if i want ot search with a 1st or 2nd dropdownlist it must show the results accoding to the 1st or 2nd dropdownlist or also if i want to search whith both dropdowns must show the reasult accoding to the two drpdowns. pleas help this is my stored-proc it works but it allows me to search with both dropdownlits but if i want search whith 1 dropdown it gives an error. pleas help if i want to search with either dropdown.

ALTER PROCEDURE [dbo].[Find_Schools]
(	
	
	@Services varchar (100),
	@Schools varchar (250)
)
	
AS
BEGIN
SET NOCOUNT ON;
SELECT  CI.CHLD_REF,CI.CHLD_ID,CI.CHLD_NAME, CI.CHLD_SURNAME, CI.CHLD_BIRTH_DATE,CI.CHLD_SchoolID, s.SVC_NAME, cs.CSVC_STATUS, cs.CSVC_UPDATE, cs.CSVC_EMPL_DN, E.Name, 
                      E.Surname,cs.CSVCID,cs.CSVC_SVC_ID
FROM         CHILD_SERVICE1 AS cs INNER JOIN
                      CHILD_INFO AS CI ON cs.CSVC_CHLD_ID = CI.CHLD_ID INNER JOIN
                      SERVICES AS s ON cs.CSVC_SVC_ID = s.SVC_ID INNER JOIN
                      EmpUsers AS E ON cs.CSVC_EMPL_DN = E.UserName
WHERE (cs.CSVC_REFERRED = 1 )and (s.SVC_NAME =@Services ) and (CI.CHLD_SchoolID = @Schools )
END

推荐答案

默认参数的概念将对您有所帮助.

参见:在SQL Server存储过程中使用可选参数 [^ ]
Concept of default parameter will help u.

see this : Using Optional Parameters in SQL Server Stored Procedures[^]


这篇关于什么是分别使用下拉菜单进行搜索的stoerdproc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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