SQL Server 2008 Full text search on a table with a composite primary key

前端 未结 2 821
轮回少年
轮回少年 2021-01-05 23:42

I am trying to put full text search working on SQL Server 2008, however the table i am trying to index is a table with a composite primary key, something like this:

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-06 00:00

    I think the error message is pretty clear, no?

    "PK_MESSAGES_C87C0C9C1EC32C6A is not a valid index to enforce a full-text search key. A full-text search key must be a unique, non-nullable, single-column index which is not offline, is not defined on a non-deterministic or imprecise nonpersisted computed column, does not have a filter, and has maximum size of 900 bytes. Choose another index for the full-text key."

    If your index is not unique, not non-nullable, and not single-column, it cannot be used for fulltext indexing.

    This means that i can't use the full text search in tables with composite primary keys? Or am i doing something wrong?

    No, as the error says - this kind of index will not work. Period. No way around it.

    As Remus pointed out - it doesn't ever say it has to be the primary key index! If you have some other non-nullable and unique field on the table, you can use a unique index on that field for your purposes. You could even just simply add a INT IDENTITY(1,1) field to your table and put a UNIQUE INDEX on that single field and you should be good to go.

提交回复
热议问题