TSQL:如何检查列是否启用了全文?

时间:2012-05-04 09:09:13

标签: sql-server tsql sql-server-2005 full-text-search

我需要修改列定义,但我想检查列是否首先启用了全文。有没有办法在TSQL脚本中进行这样的检查?

我正在使用SQL Server 2005。

2 个答案:

答案 0 :(得分:9)

您可以尝试使用COLUMNPROPERTY()功能。

DECLARE @value INT;
SELECT @value = COLUMNPROPERTY(OBJECT_ID('schema.table'), 'column_name', 'IsFulltextIndexed')

IF (@value = 1)
  PRINT 'Fulltext column'
ELSE
  PRINT 'No Fulltext column'

答案 1 :(得分:6)

您可以尝试这样的事情:

SELECT * 
FROM sys.columns c 
INNER JOIN sys.fulltext_index_columns fic ON c.object_id = fic.object_id 
                                          AND c.column_id = fic.column_id

如果您需要将其限制为给定的表格,请使用:

SELECT * 
FROM sys.columns c 
INNER JOIN sys.fulltext_index_columns fic ON c.object_id = fic.object_id 
                                          AND c.column_id = fic.column_id
WHERE c.object_id = OBJECT_ID('YourTableNameHere')