Example demo enable Full-text search in MSSQL

Source: Internet
Author: User
Tags contains mssql
How can Full-text search enable Full-text search in SQL? This article will break this problem to you through an example. This is an example of a Full-text index that is first used in Query Analyzer: www.c Hinaitpower.coml1odlwyq


Use pubs
Go www.c hinaitpower.coml1odlwyq


--Support for Open database Full-text indexing www.c hinaitpower.coml1odlwyq


Execute sp_fulltext_database ' Enable '
Go www.c hinaitpower.coml1odlwyq


--Create a Full-text catalog Ft_titles
Execute sp_fulltext_catalog ' ft_titles ', ' create '
Go www.c hinaitpower.coml1odlwyq


--To create a full-text indexed data element for the titles table, Upkcl_titleidind is the only index established by the primary key, which can be learned by sp_help titles
Execute sp_fulltext_table ' titles ', ' Create ', ' ft_titles ', ' upkcl_titleidind '
Go www.c hinaitpower.coml1odlwyq


--Set full-text index column names
EXEC sp_fulltext_column ' titles ', ' title ', ' Add '
Go
EXEC sp_fulltext_column ' titles ', ' Notes ', ' add '
Go www.c hinaitpower.coml1odlwyq


--Establish Full-text indexing
EXEC sp_fulltext_table ' titles ', ' Activate '
Go www.c hinaitpower.coml1odlwyq


--Populating Full-text index catalogs
EXEC sp_fulltext_catalog ' ft_titles ', ' start_full '
Go www.c hinaitpower.coml1odlwyq


--Using CONTAINS and FREETEXT
Select title, notes from titles
where contains (title, "" "Computer Cooking")
Go
Select title, notes from titles
where FREETEXT (title, ' Computer Cooking ')
Go
Select title, notes from titles
where FREETEXT (title, "" "Computer Cooking")
Go
Select title, notes from titles
where contains (title, ' computer ')
Go
Select title, notes from titles
where FREETEXT (*, ' computer ')
Go



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.