2011-12-14

TSQL - How to create a full text catalog, index and search

use AdventureWorks
go


-- Create the catalog
CREATE FULLTEXT CATALOG AdventureWorksFullTextCatalog;
GO


-- Create the full text index on the desired column(s)
CREATE FULLTEXT INDEX ON Production.ProductDescription
(
      Description Language 1033
)
KEY INDEX PK_ProductDescription_ProductDescriptionID
ON AdventureWorksFullTextCatalog;
GO


-- Search sample
DECLARE @SearchWord nvarchar(30);
      SET @SearchWord = N'high-performance';
SELECT
      Description
FROM
      AdventureWorks.Production.ProductDescription
WHERE
      FREETEXT(Description, @SearchWord)
;

No comments:

Post a Comment