Enable full-text retrieval function in SQL

xiaoxiao2021-03-06  41

How do I enable full-text search function in SQL? This article will take you through the example. This is an example of a full-text index, first use 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', 'Create' 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 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

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

New Post(0)