我试图使用temp变量从表中检索数据。临时变量返回正确的数据,但当试图在查询中使用它时,它不会返回正确的数据集。 我试图在查询中使用硬编码的临时值检索数据,它工作正常。任何人都可以帮我找到这个问题。选择查询中使用的Temp变量
下面是我的代码,我已经试过
Declare @tempwordFinal varchar(50)
select @tempwordFinal = ''''+'%'+'The Big Bang'+'%'+''''
select @tempwordFinal --here the output is - '%The Big Bang%'
SELECT * from MasterProgram where ProgramTitle like @tempwordFinal --not working
SELECT * from MasterProgram where ProgramTitle like '%The Big Bang%' -- working
请解释此代码的作用,请勿像这样删除代码。 – Boiethios