开发者

Full text index and parametrized query with asp.net

I've got a query builder that's been built in house which is using a full text index 开发者_JAVA技巧in order to perform description searches.

The query is built and parametrized and I was wondering the best way to encode the form field from the website in order to pass search strings such as:

  1. Covered by
  2. "red" near "yellow"
  3. red" fish

Thanks


If you want to use full text search you should use where clause with other specific functions ( not just = or like ).

@param1 will still be a string (nvarchar eventually); see here:

Querying SQL Server Using Full-Text Search

for example, you query in this way (from MSDN):

USE AdventureWorks2008R2;
GO
DECLARE @SearchWord nvarchar(30)
SET @SearchWord = N'performance'
SELECT Description 
FROM Production.ProductDescription 
WHERE CONTAINS(Description, @SearchWord);

about special chars and escaping them, just have a look here: SQL Server Full Text Search Escape Characters?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜