为什么这个 sql 语句不能赋值
问题在第三个set 语句 没有它就一切正常
declare @sql varchar(1500)
declare @keys varchar(1500)
set @sql= 'select * from [user_info_tbl] as a ,industry_tbl as b, user_tbl as c where c.user_id=a.user_id and b.industry_id=a.industry_id '
set @sql= @sql + ' and ( '
set @sql= @sql + ' c.user_mail like like ' '% ' + @keys + '% ' ' or a.user_info_country like ' '% ' + @keys + '% ' ' or a.user_info_education_High like ' '% ' + @keys + '% ' ' or a.user_info_address like ' '% ' + @keys + '% ' ' or a.user_info_credit like ' '% ' + @keys + '% ' ' or a.user_info_intro like ' '% ' + @keys + '% ' ' or a.User_info_title like ' '% ' + @keys + '% ' ' '
set @sql= @sql + ') '
print @sql
[解决办法]
嗯,没赋值会把@keys 当成null null+字符串=null