当前位置: 代码迷 >> Sql Server >> 请问存储过程中多参数查询的有关问题
  详细解决方案

请问存储过程中多参数查询的有关问题

热度:89   发布时间:2016-04-27 21:06:44.0
请教存储过程中多参数查询的问题
CREATE   PROCEDURE   selecttemp
@tname   varchar(50)   =   ' ',
@tsubject   varchar(50)   =   ' ',
@tsex   varchar(50)   =   ' ',
@tetime   varchar(50)   =   ' ',
@teadd   varchar(50)   =   ' ',
@tprice   varchar(50)   =   ' '
请问一下查询语句该如何构造呢?
SELECT   t_ID,t_Name,t_Sex,t_Educational,t_School,t_Major,t_Subject,t_E_add   FROM   Teacher  
where  
(t_Name   Like   '% '[email protected]+ '% ')and  
(t_Sex   =   @tsex)and
(t_Subject   Like   '% '[email protected]+ '% ')and
(t_E_time   =   @tetime)and
(t_E_add   =   @teadd)and
(t_Price   =   @tprice)and

------解决方案--------------------
where
(t_Name Like '% '[email protected]+ '% ')and
(t_Sex = @tsex or @tsex= ' ')and
(t_Subject Like '% '[email protected]+ '% ')and
(t_E_time = @tetime or @tetime= ' ')and
(t_E_add = @teadd or @teadd= ' ')and
(t_Price = @tprice or @tprice= ' ')and
  相关解决方案