62,046
社区成员
发帖
与我相关
我的任务
分享
Select sary_xh,sary_xb,sary_sh,sary_zhbz,sary_zhsj,sary_rylx,sary_xm,sary_zh,sary_hjdz,sary_jtgj,sary_cph,sary_wlbs,sary_hm,sary_bkrq,sydw_name from jh_sary inner join jh_sydw on jh_sary.sary_bkdw=jh_sydw.sydw_code where (sary_rylx=@Rylx) or (@Name is null or sary_xm like '%'+@Name+'%') or (@Zh is null or sary_zh like '%'+@Zh+'%') or (@Hjdz is null or sary_hjdz like '%'+@Hjdz+'%') or (sary_jtgj=@Jtgj) or (@Cph is null or sary_cph like '%'+@Cph+'%') or (sary_wlbs=@Wlbs) or (@Hm is null or sary_hm like '%'+@Hm+'%') or (sary_bkdw=@Bkdw) or (sary_bkrq between @Bkrq1 and @Bkrq2)
ALTER PROCEDURE dbo.Infosearch
(
@bmid smallint = null,
@xm varchar(10)=null,
@xb varchar(10)=null,
@strage smallint=null,
@endage smallint=null,
@zzmm varchar(10)=null,
@xl varchar(10)=null,
@zw varchar(10)=null
)
AS
/* SET NOCOUNT ON */
declare @sql varchar(100)
if @bmid is not null
begin
set @sql=' where 部门ID='+Convert(varchar(10),@bmid)
end
if @xm is not null
begin
if @sql is not null
set @sql=@sql+' and 姓名like'+@xm
else set @sql=' where 姓名like'+@xm
end
if @xb is not null
begin
if @sql is not null
set @sql=@sql+' and 性别='+@xb
else set @sql=' where 性别='+@xb
end
if @strage is not null
begin
if @sql is not null
set @sql=@sql+' and 年龄between '+Convert(varchar(10),@strage)
else set @sql=' where 年龄between '+Convert(varchar(10),@strage)
end
if @endage is not null
begin
set @sql=@sql+' and '+Convert(varchar(10),@endage)
end
if @zzmm is not null
begin
if @sql is not null
set @sql=@sql+' and 政治面貌='+@zzmm
else set @sql=' where 政治面貌='+@zzmm
end
if @xl is not null
begin
if @sql is not null
set @sql=@sql+' and 学历='+@xl
else set @sql=' where 学历='+@xl
end
if @zw is not null
begin
if @sql is not null
set @sql=@sql+' and 职位='+@zw
else set @sql=' where 职位='+@zw
end
exec('select 职工号,姓名,性别,年龄,学历,婚姻状况,政治面貌from yuangong'+@sql)
RETURN