全文搜索条件“,”中“,”附近的语法错误

时间:2019-07-11 10:32:58

标签: sql-server sql-server-2014 freetext

这是我的存储过程。当我在@BusinessName中传递“,”时,出现错误:全文搜索条件“,”中靠近“,”的语法错误。如何解决此错误?

ALTER PROCEDURE [dbo].[SearchBusiness] 
@uid bigint,
@BusinessName nvarchar(100),
@GroupId int=0
AS
BEGIN

IF ISNULL(@BusinessName,'') = '' SET @BusinessName = '""' ;

        select          
        ru.FirstName+ ' '+ru.LastName AS DisplayName,           
        ru.BusinessName
        from UserConnection uc join registereduser ru on 
        (uc.FromUserId=@uid and uc.ToUserId=ru.UserId)  
        where           
        @BusinessName = '""' OR
        contains(ru.BusinessName, @BusinessName
        ) 
END

1 个答案:

答案 0 :(得分:0)

尝试一下。

这可能对您有帮助

ALTER PROCEDURE [dbo].[SearchBusiness] 
@uid bigint,
@BusinessName nvarchar(100),
@GroupId int=0
AS
BEGIN

IF ISNULL(@BusinessName,'') = '' SET @BusinessName = '""' ;

    select          
    ru.FirstName+ ' '+ru.LastName AS DisplayName,           
    ru.BusinessName
    from UserConnection uc join registereduser ru on 
    (uc.FromUserId=@uid and uc.ToUserId=ru.UserId)  
    where           
    @BusinessName = '""' OR ru.BusinessName Like '%' + lTrim(rTrim(@BusinessName)) + '%'

END