我试图运行 sp 当我用“Like”替换“=”时它没有给出任何结果
我的查询在下面定义,
ALTER PROCEDURE [dbo].[SelectMentor]
-- Add the parameters for the stored procedure here
@Zip varchar(20)=NULL,
@Company varchar(200)=NULL,
@Designation varchar(100)=NULL,
@Interest varchar(200)=NULL
--@JobFunc varchar(200)=NULL
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
select ub.user_Id,ub.user_Fullname,up.Designation,up.Company from UserBasics UB
inner join UserProfession up on
ub.user_Id=up.Prof_ID
where (@Zip is null or ub.user_Zip = @Zip) and
(@Interest is null or ub.user_Need = @Interest) and
-- (@JobFunc is null or m.mentor_jobFunction= @JobFunc) and
(@Company is null or up.Company=@Company) and
(@Designation is null or up.Designation=@Designation)
它工作正常但是当我用“Like”替换“=”时,
select ub.user_Id,ub.user_Fullname,up.Designation,up.Company from UserBasics UB
inner join UserProfession up on
ub.user_Id=up.Prof_ID
where (@Zip is null or ub.user_Zip like '%@Zip%') and
(@Interest is null or ub.user_Need like '%@Interest%') and
-- (@JobFunc is null or m.mentor_jobFunction= @JobFunc) and
(@Company is null or up.Company like '%@Company%') and
(@Designation is null or up.Designation like '%@Designation%')
它不工作???
希望您的建议
谢谢