select name, DATABASEPROPERTY(name,'IsFulltextEnabled')
from master..sysdatabases where dbid > 4

select fulltextserviceproperty('isfulltextinstalled') 

--EXEC sp_fulltext_database 'enable'
ALTER FULLTEXT INDEX ON [dbo].[tblTable01] START FULL POPULATION; 

ALTER FULLTEXT INDEX ON [dbo].[tblTable01] START INCREMENTAL POPULATION;
SELECT
    FULLTEXTCATALOGPROPERTY(cat.name,'ItemCount') AS [ItemCount],
    FULLTEXTCATALOGPROPERTY(cat.name,'MergeStatus') AS [MergeStatus],
    FULLTEXTCATALOGPROPERTY(cat.name,'PopulateCompletionAge') AS [PopulateCompletionAge],
    FULLTEXTCATALOGPROPERTY(cat.name,'PopulateStatus') AS [PopulateStatus],
    FULLTEXTCATALOGPROPERTY(cat.name,'ImportStatus') AS [ImportStatus],
    FULLTEXTCATALOGPROPERTY(cat.name,'IndexSize') AS [IndexSize MB],
    FULLTEXTCATALOGPROPERTY(cat.name,'UniqueKeyCount') AS [UniqueKeyCount]
FROM sys.fulltext_catalogs AS cat
DECLARE @CatalogName VARCHAR(MAX)
SET     @CatalogName = 'ftcMyCatalogName'

SELECT
    DATEADD(ss, FULLTEXTCATALOGPROPERTY(@CatalogName,'PopulateCompletionAge'), '1/1/1990') AS LastPopulated
    ,(SELECT CASE FULLTEXTCATALOGPROPERTY(@CatalogName,'PopulateStatus')
        WHEN 0 THEN 'Idle'
        WHEN 1 THEN 'Full Population In Progress'
        WHEN 2 THEN 'Paused'
        WHEN 3 THEN 'Throttled'
        WHEN 4 THEN 'Recovering'
        WHEN 5 THEN 'Shutdown'
        WHEN 6 THEN 'Incremental Population In Progress'
        WHEN 7 THEN 'Building Index'
        WHEN 8 THEN 'Disk Full.  Paused'
        WHEN 9 THEN 'Change Tracking' END) AS PopulateStatus
CREATE PROCEDURE WaitForFullTextIndexing
@CatalogName VARCHAR(MAX)
AS
BEGIN
    DECLARE @status int;
    SET @status = 1;
    DECLARE @waitLoops int;
    SET @waitLoops = 0;

    WHILE @status > 0 AND @waitLoops < 100
    BEGIN       
        SELECT @status = FULLTEXTCATALOGPROPERTY(@CatalogName,'PopulateStatus')
        FROM sys.fulltext_catalogs AS cat;

        IF @status > 0
        BEGIN
            -- prevent thrashing
            WAITFOR DELAY '00:00:00.1';
        END
        SET @waitLoops = @waitLoops + 1;
    END
END

Sources:

https://docs.microsoft.com/en-us/sql/relational-databases/search/create-and-manage-full-text-indexes?view=sql-server-ver15

https://docs.microsoft.com/en-us/sql/relational-databases/search/populate-full-text-indexes?view=sql-server-ver15

https://stackoverflow.com/questions/2727911/how-can-i-know-when-sql-full-text-index-population-is-finished

Last modified: December 4, 2019

Author

Comments

Write a Reply or Comment