1

I am declaring a new stored procedure in MS SQL Server for implementing Full Text Search and my query is some thing like this:

Select * from table WHERE FREETEXT((col1, col2), @Search_Statement)

The question has exactly written bellow:

What is the proper data type for @Search_Statement variable to support most of searches and also have the best performance?

(I know that if I make @Search_Statement variable long it supports more search queries but executing queries with longer @Search_Statement may affect performance and google limit search queries to 32 words: https://www.linkedin.com/grp/post/1176637-216124982)

I don't know which of these datatypes to use for @Search_Statement in my stored procedure: Nvarchar(100), Nvarchar(500) or Nvarchar(MAX) Which would be the best choice? (Performance, and all other aspects)

Update: I know I should use nvarchar but what is proper size of nvarchar? nvarchar(100),(200),(500),... or even nvarchar(MAX)?

4

1 回答 1

2

According to FREETEXT Documentation

FREETEXT ( { column_name | (column_list) | * } , 'freetext_string' [ , LANGUAGE language_term ] )

freetext_string is nvarchar. An implicit conversion occurs when another character data type is used as input. In the following example, the @SearchWord variable, which is defined as varchar(30), causes an implicit conversion in the FREETEXT predicate.

于 2015-08-23T14:03:48.277 回答