Full-text retrieval using SQL Server 2000

Source: Internet
Author: User

Today, we are studying the full-text retrieval function of SQL Server. Some good information found on the Internet:

[SQLSERVER] Full-text retrieval in SQL)
Instance demonstration enable full-text search in SQL
Use full-text retrieval of SQL SERVER 2000
SQL Server 2000 full-text retrieval technology

The Search syntax and parameters in the above articles are not detailed enough. The following is a detailed description:

SQL Server 2000 provides the following full-text search statements: CONTAINS and FREETEXT.

CONTAINS:
The CONTAINS statement is used to search for a word or phrase in all or specified columns of a table. The prefix of a word or phrase is similar to that of a word; A derived word of a word; a repeated word.

The syntax format of the CONTAINS statement is:

CONTAINS ({column | *}), <contains_search_condition>)

Column is a search column. When "*" is used, it indicates that all full-text index columns in the table are searched.
Contains_search_condition describes the search content of the CONTAINS statement. Its Syntax format is:

{<Simple_term> | <prefix_term> | <proximity_term> | <generation_term> | <weighted_term >}[ {AND | and not | OR} <contains_search_condition>}] [... n]

The simple_term and prefix_term parameters are briefly described below:

Simple_term is the word or phrase searched by the CONTAINS statement. When searching for a phrase, double quotation marks must be used as the delimiter. The format is:

{'Word' | "phrase "}

Prefix_term indicates the prefix of the word or phrase searched by the CONTAINS statement. The format is:

{"Word *" | "phrase *"}

For example, the following statement retrieves the name of a Book containing the "database" or "computer" string and Its annotation information in the Title column and Notes column of the Book table:

Select title, notes
From book
Where contains (tilte, 'database') or contains (notes, 'database ')
Or contains (title, 'computer ') or contains (notes, 'computer ')

FREETEXT

The FREETEXT statement is used to search for a free text string in all or specified columns of a table and return data rows matching the string. Therefore, the FREETEXT statement is also called a free full-text query.

The syntax format of the FREETEXT statement is: FREETEXT ({column | *}, 'freetext _ string ')

Column is the column to be searched. If "*" is used, all full-text index columns in the table are searched. The Freetext_string parameter indicates the searched free text format string.

For example, the following statement uses the FREETEXT statement to search data rows in the Book table that contain the "craft" and "mechanical" strings. Note that the SQL syntax name divides the string into two words for search:

Select *
From trade
Where freetext (*, 'process mechanically ')

In addition to the full-text Search service provided by SQL Server, Microsoft Indexing Services and third-party Search components are provided.
The following articles about Index Service are worth reading:
Use Microsoft Indexing Services to develop full-text search configurations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.