我想根据存储过程输入构建自定义 Where 条件,如果不为空,那么我将在语句中使用它们,否则我不会使用它们。
if @Vendor_Name is not null
begin
set @where += 'Upper(vendors.VENDOR_NAME) LIKE "%"+ UPPER(@Vendor_Name) +"%"'
end
else if @Entity is not null
begin
set @where += 'AND headers.ORG_ID = @Entity'
end
select * from table_name where @where
但我得到这个错误
An expression of non-boolean type specified in a context where a condition is expected, near 'set'.