--1 Enabling Full Text on the Database
EXEC sp_fulltext_database 'enable'
--2 Create the Catalog (if does not exist)
EXEC sp_fulltext_catalog 'MyCatalog','create'
--3 Add a Full Text Index on a Table
EXEC sp_fulltext_table 'Products', 'create', 'MyCatalog', 'pk_products'
EXEC sp_fulltext_table 'Categories', 'create', 'MyCatalog', 'pk_categories'
--4 Add a Column to the Full Text Index
EXEC sp_fulltext_column 'Products', 'ProductName', 'add'
EXEC sp_fulltext_column 'Categories', 'Description', 'add'
--5 Activate the Index
EXEC sp_fulltext_table 'Products','activate'
EXEC sp_fulltext_table 'Categories','activate'
--6 Start Full Population
EXEC sp_fulltext_catalog 'MyCatalog', 'start_full'
-- Usage in T-SQL (CONTAINS and FREETEXT Predicates)
-- Using the Index in T-SQL
USE Northwind
GO
SELECT ProductId, ProductName, UnitPrice
FROM Products
WHERE CONTAINS(
ProductName, ' "sasquatch " OR "stout" '
)
GO
USE Northwind
GO
SELECT CategoryName
FROM Categories
FREETEXT (
Description, 'sweetest candy bread and dry meat'
)
GO