我有两个 简单的存储过程可不知道为什么会这样
第一个
CREATE PROCEDURE lanchina_person_manage
as
select bm_yuangong.*,
case bm_yuangong.Person_zhuangtai
WHEN 0 THEN '离职 '
WHEN 1 THEN '试用在职 '
WHEN 2 THEN '正式在职 '
end as Person_zhuangtai1
from bm_yuangong
where Person_zhuangtai <> '0 '
order by person_id desc
GO
可以正常使用
我在查询里 同样使用了类似的存储过程
是这样写的
CREATE PROCEDURE lanchina_person_managetwo
@new_select varchar(50),
@new_key varchar(50)
as
select bm_yuangong.*,
case bm_yuangong.Person_zhuangtai
WHEN 0 THEN '离职 '
WHEN 1 THEN '试用在职 '
WHEN 2 THEN '正式在职 '
end as Person_zhuangtai1
from bm_yuangong
where '+@new_select+ ' like "% '+@new_key+ '% " and Person_zhuangtai <> '0 '
order by person_id desc
GO
这第二个 没有语法错误 却怎么都查询不出借过 请问这是为什么 谢谢大家 急急急!!!
------解决方案--------------------这样改一下第二个存储过程:
CREATE PROCEDURE lanchina_person_managetwo
@new_select varchar(50),
@new_key varchar(50)
as
declare @sql varchar(8000)
set @sql = '
select bm_yuangong.*,
case bm_yuangong.Person_zhuangtai
WHEN 0 THEN ' '离职 ' '
WHEN 1 THEN ' '试用在职 ' '
WHEN 2 THEN ' '正式在职 ' '
end as Person_zhuangtai1
from bm_yuangong
where '+@new_select+ ' like ' '% '+@new_key+ '% ' ' and Person_zhuangtai <> ' '0 ' '
order by person_id desc '
EXEC(@sql)
GO
------解决方案--