请教SQL语句问题
下面这条语句老是调试不过
老是提示like附近出错 到底错在哪里呢
set @strSql = 'insert into #indextable(CompanyID,CompanyName,Address,Phone,Place) '+
'select CompanyID, CompanyName,Address,Phone,Place from Companywhere Place like % '+@strPlace+ '% '
exec(@strSql)
[解决办法]
--try
set @strSql = 'insert into #indextable(CompanyID,CompanyName,Address,Phone,Place) '+
'select CompanyID, CompanyName,Address,Phone,Place from Companywhere Place like ' '% '+@strPlace+ '% ' ' '
exec(@strSql)
[解决办法]
set @strSql = 'insert into #indextable(CompanyID,CompanyName,Address,Phone,Place) '+
'select CompanyID, CompanyName,Address,Phone,Place from Company where Place like ' '% '+@strPlace+ '% ' ' '
exec(@strSql)
[解决办法]
少空格啦!
set @strSql = 'insert into #indextable(CompanyID,CompanyName,Address,Phone,Place) '+
'select CompanyID, CompanyName,Address,Phone,Place from Company where Place like % '+@strPlace+ '% '
exec(@strSql)
[解决办法]
因为本来正常情况下like后边就要有 ' '来包含
所以这里单引号涉及到变量的调用和字符串的填充,
所以 Place like ' '% '+@strPlace+ '% ' '