How do I enable full-text search function in SQL?

xiaoxiao2021-03-06  77

An example of a full-text index, used in the query analyzer:

USE PUBS

Go

- Open the support of the database full-text index

EXECUTE SP_FULLTEXT_DATABASE 'Enable'

Go

- Establish a full-text catalog FT_TITLES

Execute sp_fultext_catalog 'ft_titles', 'crete'

Go

- Establish a full-text index data for the Titles table, UPKCL_TITLEIDIND is the unique index established by the primary key, can be known from sp_help titles

Execute sp_fultext_table 'titles', 'create', 'ft_titles', 'UPKCL_TITLEIDIND'

Go

- Set the full-text index column name

EXEC SP_FULLTEXT_COLUMN 'TITLES', 'Title', 'Add'

Go

EXEC SP_FULLTEXT_COLUMN 'TITLES', 'NOTES', 'Add'

Go

- Establish a full-text index

EXEC SP_FULLTEXT_TABLE 'TITLES', 'ACTIVATE'

Go

- Fill full-text index directory

EXEC SP_FULLTEXT_CATALOG 'FT_TITLES', 'Start_Full'

Go

- Use Contains and Freetext

SELECT TIM, Notes from Titles

WHERE Contains (Title, '"Computer Cooking")

Go

SELECT TIM, Notes from Titles

WHERE FREETEXT (Title, 'Computer Cooking')

Go

SELECT TIM, Notes from Titles

WHERE FREETEXT (Title, '"Computer Cooking")

Go

SELECT TIM, Notes from Titles

WHERE Contains (Title, 'Computer')

Go

SELECT TIM, Notes from Titles

WHERE FREETEXT (*, 'Computer')

Go

转载请注明原文地址:https://www.9cbs.com/read-97876.html

New Post(0)