下面这条语句老是调试不过
老是提示like附近出错 到底错在哪里呢 set @strSql = 'insert into #indextable(CompanyID,CompanyName,Address,Phone,Place)'+
'select CompanyID, CompanyName,Address,Phone,Place from Companywhere Place like %'+@strPlace+'%'
exec(@strSql)
老是提示like附近出错 到底错在哪里呢 set @strSql = 'insert into #indextable(CompanyID,CompanyName,Address,Phone,Place)'+
'select CompanyID, CompanyName,Address,Phone,Place from Companywhere Place like %'+@strPlace+'%'
exec(@strSql)
'select CompanyID, CompanyName,Address,Phone,Place from Companywhere Place like ''%'+@strPlace+'%'''
exec(@strSql)
'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)
'select CompanyID, CompanyName,Address,Phone,Place from Company
where Place like %'+@strPlace+'%'exec(@strSql)
所以这里单引号涉及到变量的调用和字符串的填充,
所以 Place like ''%'+@strPlace+'%''
'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)
错误地方有2处:一个是where前没加空格; 另一个是两个%要加单引号。