我试图将可搜索的列作为参数传递给存储过程,但它永远不会工作
contains(@RTitleColumn, @searchTerm)
我将@RtitleColumn作为第一个CONTAINS参数传递
这是完整的查询
SELECT Lid As ItemID, Lhits As Hits, LImageID As ImageID, LNAME As Title
, LCategory AS CategoryID, Lactive AS isActive,LRate AS SumRate,LRAteNo AS CommentCount,
ROW_NUMBER() OVER (ORDER BY LID desc) AS RowRank
FROM dbo.tblRecipes
where
contains(@RTitleColumn, @searchTerm) and (@Activeflag is null or LActive=@Activeflag)
答案 0 :(得分:0)
(假设参数@ searchTerm
被声明为nvarchar(50)
Declare @MainSQL nvarchar(200)
set @MainSQL =
N'SELECT Lid As ItemID, Lhits As Hits,LImageID As ImageID,
LNAME As Title, LCategory AS CategoryID, Lactive AS isActive,
LRate AS SumRate,LRAteNo AS CommentCount,
ROW_NUMBER() OVER (ORDER BY LID desc) AS RowRank
FROM dbo.tblRecipes
where
contains(' + @RTitleColumn + ', @searchTerm)'
Execute sp_executesql, @MainSQL, N'@searchTerm nvarchar(50)',@searchTerm = @searchTerm