This scenario demonstrates how to use SQL Server Service Manager to enable others to issue full-text queries against the writers and books tables. This example assumes that some tables have been added to the pubs database.
If necessary, the service can be started and stopped in one of these ways:
SELECT DatabaseProperty ('Pubs', 'IsFulltextEnabled' )
This returns 1 if full-text support has been enabled, and 0 if it has not.
sp_fulltext_database 'enable'
sp_fulltext_catalog 'PubsCatalog', 'create'
This creates metadata about a full-text catalog in the database’s system tables and builds an empty full-text catalog in the file system.
sp_fulltext_table 'writers', 'create', 'PubsCatalog',
'writer_id_index'
sp_fulltext_table 'books', 'create', 'PubsCatalog', 'isbn_index'
Both tables use the PubsCatalog full-text catalog. These calls create metadata about both full-text indexes.
sp_fulltext_column 'writers', 'organization', 'add'
sp_fulltext_column 'writers', 'bio', 'add'
sp_fulltext_column 'books', 'writer_name', 'add'
sp_fulltext_column 'books', 'the words', 'add'
sp_fulltext_column 'books', 'abstract', 'add'
Note A mistake was made for the sake of illustration: for the books table, the writer_name column, rather than the titles column, has been registered.
These calls augment metadata about both full-text indexes.
sp_fulltext_table 'writers', 'activate'
sp_fulltext_table 'books', 'activate'
This does not actually create the full-text indexes. Rather, it registers the tables in the full-text catalog so that data from these tables will be included in the next population.
sp_fulltext_catalog 'PubsCatalog', 'start_full'
Because the population of a full-text catalog is an asynchronous operation, it is unlikely that the full-text indexes are created immediately.
SELECT FulltextCatalogProperty ( 'PubsCatalog', 'PopulateStatus')
This returns 0 if the service is idle for the full-text catalog and therefore finished, and 1 or more to indicate various stages of population.
SELECT B.writer_name, B.pub_date, B.the_words, A.royalties_ytd
FROM writers A, books B
WHERE A.writer_name = B.writer_name
AND A.citizenship = 'Canadian'
AND CONTAINS (B.the_words, '"Indexing Service" NEAR "Indexing Service"')
SELECT writer_name, pub_date, abstract
FROM books
WHERE CONTAINS (title, '"Classic" NEAR "French" NEAR "Cooking"')
This last query results in an error because the title column was not enabled for full-text queries.
SELECT ColumnProperty ( ObjectId('books'), 'title', 'IsFullTextIndexed' )
This returns 1 if the title column is part of the full-text index for the books table, and 0 if it is not.
sp_help_fulltext_columns 'books'
Note The results of this query show that there was a mistake and that the writer_name column, rather than the title column, was included in the full-text index definition.
sp_fulltext_table 'books', 'deactivate'
In addition to allowing columns to be added and deleted, deactivating the books table means that the table no longer participates in the population of the PubsCatalog full-text catalog. However, the metadata remains and the table can be reactivated. The existing full-text index for the books table remains in place until the next full population of the PubsCatalog full-text catalog, but it is unused because Microsoft® SQL Server™ blocks queries on deactivated tables.
sp_fulltext_column 'books', 'writer_name', 'drop'
sp_fulltext_column 'books', 'title', 'add'
sp_fulltext_table 'books', 'activate'
If the table is reactivated and the index is not repopulated, the old index is still available for queries against the full-text enabled columns that remain, but not for queries against any new full-text enabled columns. Before repopulation, data from deleted columns can be matched on queries that specify a search of all full-text columns by typing an asterisk (*) for the column name.
sp_fulltext_catalog 'PubsCatalog', 'start_incremental'
An incremental population refreshes the full-text catalog by indexing data in full-text enabled columns with these characteristics: