I want to create a full text index but I am not sure if the index name is the same in all databases. So, I plan to write the below select and get the name of the index.
DECLARE @keyIndex NVARCHAR(100)
SELECT @keyIndex = name FROM sysobjects WHERE xtype = 'PK' AND parent_obj = OBJECT_ID(N'[dbo].[Table1]')
Below is the Create statement for full text index which I have tried:
CREATE FULLTEXT INDEX ON dbo.Table1
(
[Name] Language 1033,
[Description] Language 1033
)
KEY INDEX [@keyIndex]
WITH STOPLIST = SYSTEM, CHANGE_TRACKING AUTO;
It gives this error:
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.
I need some help on how to dynamically insert the value for key index.