2
我想创建一个全文索引,但我不确定索引名称是否在所有数据库中都是相同的。所以,我打算写下面的选择并获取索引的名称。通过查询索引名称创建全文索引
DECLARE @keyIndex NVARCHAR(100)
SELECT @keyIndex = name FROM sysobjects WHERE xtype = 'PK' AND parent_obj = OBJECT_ID(N'[dbo].[Table1]')
以下是全文索引创建语句,我曾尝试:
CREATE FULLTEXT INDEX ON dbo.Table1
(
[Name] Language 1033,
[Description] Language 1033
)
KEY INDEX [@keyIndex]
WITH STOPLIST = SYSTEM, CHANGE_TRACKING AUTO;
它给出了这样的错误:
Msg 7653, Level 16, State 1, Line 11
'@keyIndex' 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.
我需要如何动态地插入一些帮助关键指标值。
不行的,给人错误 - 附近有语法错误@keyIndex“。期待ID或Quoted_ID – stech
看我的编辑。现在应该工作。 – Botis
仍然无法使用。在With子句附近获得语法错误。 – stech