There is a problem occurs when I search data using full-text search with SQL Server 2008.
When I search data with no blank space it works but when I enter data with blank spaces it gives an error.
Like if I search 'amit'
it works but if data is 'amit is working'
it gives error.
I am using ASP.NET MVC 4.0 with SQL Server 2008.
Thanks Amit.
Create PROC [usp_Feedback_Search]
@Word nvarchar(500) ,
@CompanyId UNIQUEIDENTIFIER
As
IF ISNULL(@Word,'') = ''
BEGIN
Select
[Id] ,
[Content] ,
[UserId],
[VoteCount] ,
[IsOpen],
[Deleted],
[RowVersion],
[CreatedBy],
[CreatedOn],
[UpdatedOn],
[UpdatedBy],
[CompanyId],
[DisplayId],
[Status]
FROM Feedback
WHERE CompanyId=@CompanyId
END
ELSE
BEGIN
DECLARE @formatedWord varchar(500)='"'+@word+'\+"'
Select
[Id] ,
[Content] ,
[UserId],
[VoteCount],
[IsOpen],
[Deleted],
[RowVersion],
[CreatedBy],
[CreatedOn],
[UpdatedOn],
[UpdatedBy],
[CompanyId],
[DisplayId],
[Status]
FROM Feedback
Where CONTAINS(*,@Word)
and CompanyId=@CompanyId
END
GO
I think Amit's answer may be unique to Amit. For everyone else...
wrap the value in double quotes:
SELECT ... WHERE Contains(tablename.columnname, '"amit is working"')
is the answer to
There is a problem occurs when I search data using full-text search with SQL Server 2008.
When I search data with no blank space it works but when I enter data with blank spaces it gives an error.
Like if I search 'amit' it works but if data is 'amit is working' it gives error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With