I'd like to create a 开发者_Go百科fulltext index on several columns which are varchars
and numbers. And there is the problem with the numbers.
Is there really no way to add column as number or decimal for the fulltext index?
I've got for example a table article:
CREATE TABLE article
( articleid number(10) not null,
articlename varchar(50) not null,
articlecode1 varchar(50)
);
CREATE FULLTEXT CATALOG MyCatalog;
CREATE FULLTEXT INDEX ON artikel
(articleid LANGUAGE 0x0,
articlename LANGUAGE 0x0,
articlecode1 LANGUAGE 0x0)
KEY INDEX PK_ARTICLE ON MyCatalog
WITH CHANGE_TRACKING AUTO;
It couldn't be created, because articleid
is a number!
My alternate solution is to create a second column such as articleidtext varchar
as a copy of articleid. Afterward to fill up with a trigger.
Is there really no other way?
I've tried also to Cast like: CAST(articleid AS varchar) LANGUAGE 0x0
it doesn't work either.
any other suggestion??
thx...
You can create a computed, persisted column of type VARCHAR
based on your articleId
- this doesn't need to be filled with a trigger or anything, it will always represent the articleId
, but as a VARCHAR
column, and thus it can be fulltext indexed:
ALTER TABLE dbo.article
ADD ArticleIDText AS CAST(ArticleID AS VARCHAR(20)) PERSISTED
Now put your fulltext index on ArticleIDText
and everything should be just fine....
You cannot create Fulltext indexes on columns which are numbers. If you want to be able to search it using full text, u can convert the column to a string.
But the real question is are you looking for full text index or just a normal index!?
fulltext works only with types :
char, varchar, nchar, nvarchar, text, ntext, image, xml или varbinary(max)
精彩评论