0
我有這個SQL查詢,我試圖使用CONTAINS搜索標題字段。如何在SQL Server 2008中使用CONTAINS和inline查詢?
但我得到這個錯誤。
「Can not use CONTAINS or FREETEXT predicate on column'Title',because it's not full-text indexed。」
標題表已被編入索引,CONTAINS可以通過簡單搜索正常工作。
有誰知道我在做什麼錯?內聯查詢不支持CONTAIN查詢嗎?
此查詢是在SQL Server 2008跑去
SELECT pi.PublisherGUID, pi.Publisher, pi.TitleGUID, pi.Title,
pi.YearsPublished, pi.FrontImage, pi.IssueGUID, pi.IssueNumber,
pi.IssueVariation, pi.IssueNotes, pi.CoverDate, pi.IsForSale
FROM (
SELECT ROW_NUMBER() OVER(ORDER BY PublicIssues.Title,PublicIssues.IssueNumber) AS RowNum,
PublicIssues.PublisherGUID, PublicIssues.Publisher,
PublicIssues.TitleGUID, PublicIssues.Title,
PublicIssues.YearsPublished, PublicIssues.FrontImage,
PublicIssues.IssueGUID, PublicIssues.IssueNumber,
PublicIssues.IssueVariation, PublicIssues.IssueNotes,
PublicIssues.CoverDate, PublicIssues.IsForSale
FROM (SELECT dbo.tblTitles.PublisherGUID, dbo.tblPublishers.Name AS Publisher,
dbo.tblTitles.TitleGUID, dbo.tblTitles.Title,
dbo.tblTitles.YearsPublished, dbo.tblIssues.IssueGUID,
dbo.tblIssues.IssueNumber, dbo.tblIssues.IssueVariation,
dbo.tblIssues.IssueNotes, dbo.tblIssues.CoverDate,
dbo.tblStockIssueImages.FrontImage,
ci_owner.IssueForSale(dbo.tblIssues.IssueGUID) AS IsForSale
FROM dbo.tblStockIssueImages RIGHT OUTER JOIN
dbo.tblIssues ON
dbo.tblStockIssueImages.StockIssueImageGUID = dbo.tblIssues.StockIssueImageGUID
LEFT OUTER JOIN
dbo.tblTitles INNER JOIN
dbo.tblPublishers ON dbo.tblTitles.PublisherGUID = dbo.tblPublishers.PublisherGUID
ON dbo.tblIssues.TitleGUID = dbo.tblTitles.TitleGUID
)
AS PublicIssues
WHERE 1=1 AND CONTAINS(Title,@xTitle)
) AS pi
WHERE RowNum BETWEEN (@xPageNum - 1) * @xPageSize + 1 AND
@xPageNum * @xPageSize ORDER BY pi.Title
爲了解決這個問題,可能你只需要創建一個整個子查詢作爲一個臨時表,並創建在該臨時表中的全文索引,然後從選擇? – SqlRyan 2009-11-22 03:53:08
你可能只是:a)你將不得不打破3中的查詢(選擇/創建臨時表,FT索引,從中搜索),更重要的是,創建FT索引可能需要比預期更長的時間。 – mjv 2009-11-22 03:59:39
我猜SQLServer是不夠聰明,知道該字段在子查詢中使用時索引。你認爲這是因爲你必須選擇你想要索引的字段。 – 2009-11-23 01:23:27