动态Sql出错
set @sql=N'SELECT a.ID,Title,AddDate ' +@tablename+ ' a INNER JOIN @Products b ON CHARINDEX(b.keyWord,a.Title)>0 WHERE CONTAINS(Title,@contains) GROUP BY a.ID,Title,AddDate ORDER BY Sum(keyNum) DESC,COUNT(DISTINCT keyword),AddDate desc'print @sqlexec sp_executesql @sql
SELECT a.ID,Title,AddDate FS_News a INNER JOIN @Products b ON CHARINDEX(b.keyWord,a.Title)>0 WHERE CONTAINS(Title,@contains) GROUP BY a.ID,Title,AddDate ORDER BY Sum(keyNum) DESC,COUNT(DISTINCT keyword),AddDate desc消息 102,级别 15,状态 1,第 1 行'a' 附近有语法错误。