0

我正在尝试将可搜索列作为参数传递给存储过程,但它永远不会起作用

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)
4

1 回答 1

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
于 2016-02-29T05:13:25.217 回答