我目前正試圖添加一個FULLTEXT索引,以便能夠在包含關鍵詞的敘述欄中搜索關鍵詞。我已經嘗試了許多不同的教程,雖然我完全複製它們,但我無法在「WHERE」部分中使用'CONTAINS'功能時複製結果。SQL - FULLTEXT INDEX
下面是我使用一些示例數據的腳本示例。有人能夠向我解釋爲什麼這不起作用,因爲我正在認真努力地看到錯誤可能在哪裏。
CREATE TABLE dbo.AAAA_FullTextTest5
(ID INT Identity(1, 1) NOT NULL
,LOCATION VARCHAR (255)
,NARRATIVE VARCHAR(MAX)
)
ALTER TABLE dbo.AAAA_FullTextTest5 add constraint PK_FullTextTest5 PRIMARY KEY (ID)
INSERT INTO dbo.AAAA_FullTextTest5 (LOCATION, NARRATIVE) VALUES ('USA Texas', 'WRIGHT BROTHERS')
INSERT INTO dbo.AAAA_FullTextTest5 (LOCATION, NARRATIVE) VALUES ('Worldwide', 'CROWN PROS Builders LTD')
INSERT INTO dbo.AAAA_FullTextTest5 (LOCATION, NARRATIVE) VALUES ('Devon United Kingdom', 'J PJH ROOFING LTD')
INSERT INTO dbo.AAAA_FullTextTest5 (LOCATION, NARRATIVE) VALUES ('UK', 'Shoreham Port Authority and Shoreham Port Developments & The Port of Shoreham Trustees ')
INSERT INTO dbo.AAAA_FullTextTest5 (LOCATION, NARRATIVE) VALUES ('EUROPE AND RUSSIA', 'ZHY SERVICES')
INSERT INTO dbo.AAAA_FullTextTest5 (LOCATION, NARRATIVE) VALUES ('Austrialia', 'BrotherLimited')
INSERT INTO dbo.AAAA_FullTextTest5 (LOCATION, NARRATIVE) VALUES ('ASIA', 'DRILLING SERVICES LTD')
INSERT INTO dbo.AAAA_FullTextTest5 (LOCATION, NARRATIVE) VALUES ('JAPAN', 'BROOKS WASTE LTD')
INSERT INTO dbo.AAAA_FullTextTest5 (LOCATION, NARRATIVE) VALUES ('Melbourne', 'TRC Service Company')
INSERT INTO dbo.AAAA_FullTextTest5 (LOCATION, NARRATIVE) VALUES ('GERMANY & HOLLAND', 'Samson Group')
INSERT INTO dbo.AAAA_FullTextTest5 (LOCATION, NARRATIVE) VALUES ('Frankfurt', 'SCAFFOLDING LTD')
INSERT INTO dbo.AAAA_FullTextTest5 (LOCATION, NARRATIVE) VALUES ('Swindon, England', 'Scaffold Access Ltd')
CREATE FULLTEXT CATALOG FullTextTest5
CREATE FULLTEXT INDEX ON dbo.AAAA_FullTextTest5 (
Location language 1033
,Narrative language 1033)
KEY INDEX PK_FullTextTest5 ON FullTextTest5
WITH CHANGE_TRACKING AUTO
SELECT * FROM dbo.AAAA_FullTextTest5
WHERE CONTAINS(NARRATIVE, 'Access')
哪個dbms? (這是產品特定的功能....) – jarlh 2015-03-25 12:29:50
你能澄清它爲什麼不起作用嗎?任何錯誤,或只是不是你期望的結果(如果是的話)? – 2015-03-25 12:47:27
運行時不會出現錯誤。它只是沒有結果被返回,我不明白爲什麼基於至少有一個結果與單詞'訪問'在其中。 – bwsutton 2015-03-25 13:49:26