Share via


전체 텍스트 검색 및 Transact-SQL 조건자 통합

CONTAINS 및 FREETEXT 조건자는 LIKE, BETWEEN 등의 다른 Transact-SQL 조건자와 결합할 수 있으며 하위 쿼리에서 사용할 수도 있습니다. 이 예에서는 설명 ID가 5가 아니고 설명에 "Aluminum" 및 "spindle"이라는 단어가 포함된 설명을 검색합니다.

USE AdventureWorks;
GO
SELECT Description
FROM Production.ProductDescription
WHERE ProductDescriptionID <> 5 AND
   CONTAINS(Description, ' Aluminum AND spindle');
GO

다음 쿼리는 하위 쿼리에서 CONTAINS를 사용합니다. AdventureWorks 데이터베이스를 사용하면 이 쿼리는 특정 주기에 대한 ProductReview 테이블의 모든 설명 값을 얻습니다.

USE AdventureWorks;
GO
INSERT INTO Production.ProductReview 
(ProductID, ReviewerName, EmailAddress, Rating, Comments) 
VALUES
(780, 'John Smith', 'john@fourthcoffee.com', 5, 
'The Mountain-200 Silver from AdventureWorks Cycles meets and exceeds expectations. I enjoyed the smooth ride down the roads of Redmond')
 -- Given the full-text catalog for these tables is Adv_ft_ctlg, 
-- with change_tracking on so that the full-text indexes are updated automatically.
WAITFOR DELAY '00:00:30'   
-- Wait 30 seconds to make sure that the full-text index gets updated.
  SELECT r.Comments, p.Name
FROM Production.ProductReview r
JOIN Production.Product p 
ON
 r.ProductID = p.ProductID
 AND r.ProductID = (SELECT ProductID
                  FROM Production.ProductReview
                  WHERE CONTAINS (Comments, 
                                 ' AdventureWorks AND 
                                   Redmond AND 
                                   "Mountain-200 Silver" '))

GO

참고 항목

관련 자료

CONTAINS(Transact-SQL)
FREETEXT(Transact-SQL)
WHERE(Transact-SQL)

도움말 및 정보

SQL Server 2005 지원 받기