SharePoint / ASP.Net Development
Experiences from the field...
Navigation
   RSS 2.0
Categories
Entries by Month

# Monday, January 03, 2005

UPDATE: John points out “It should be noted that when you change the setting to CT with UIiB, an automatic Full or Incremental (depending upon the presence of a timestamp column) is executed to re-sync the table data with the FT Catalog.“  I missed this when I posted, but new visitors should be aware of this. Thanks John!


John Kane came across my post on the forums at Joel on Software about full-text indexing on SQL Server. I suggested that I could post a script that sets all of the tables in an index to background change tracking, but I never did make that post.

So, here is a T-SQL script that will check every table in every catalog in the current database:

DECLARE @FTCatID smallint, @FTPath nvarchar(260), @FTStatus int
DECLARE @FTName sysname, @FTNbrTbls int DECLARE @csr_FT CURSOR

DECLARE @FTTOwner sysname, @FTTName sysname, @FTTIndex sysname
DECLARE @FTTColid int, @FTTActive int, @FTTCat sysname
DECLARE @csr_FTT CURSOR

-- Get all the catalogs in the current database
EXEC sp_help_fulltext_catalogs_cursor @csr_FT OUTPUT
FETCH NEXT FROM @csr_FT INTO @FTCatID, @FTName, @FTPath, @FTStatus, @FTNbrTbls
WHILE (@@FETCH_STATUS = 0)
BEGIN

-- Get all the tables in this catalog

print @FTName
EXEC sp_help_fulltext_tables_cursor @csr_FTT OUTPUT, @FTName
FETCH NEXT FROM @csr_FTT INTO @FTTOwner, @FTTName, @FTTIndex, @FTTColid, @FTTActive, @FTTCat

WHILE (@@FETCH_STATUS = 0)
BEGIN

print ' ' + @FTTName
EXEC sp_fulltext_table @FTTName, 'Start_change_tracking'
EXEC sp_fulltext_table @FTTName, 'Start_background_updateindex'

FETCH NEXT FROM @csr_FTT INTO @FTTOwner, @FTTName, @FTTIndex, @FTTColid, @FTTActive, @FTTCat

END

CLOSE @csr_FTT

DEALLOCATE @csr_FTT

FETCH NEXT FROM @csr_FT INTO @FTCatID, @FTName, @FTPath, @FTStatus, @FTNbrTbls END

CLOSE @csr_FT
DEALLOCATE @csr_FT

 

If your server is setup like mine, you might have multiple databases on the server. If you want to run the above script on all the databases, here is a VBScript to do so:

dim oServer, oDB, oFS, oFile
dim sCmdBatch

Set oFS = CreateObject("Scripting.FileSystemObject")
Set oFile = oFS.OpenTextFile("FT_change_tracking.sql")
sCmdBatch = oFile.ReadAll

Set oServer = CreateObject("SQLDMO.SQLServer")

WScript.Echo "Connecting..."
oServer.LoginSecure = True
oServer.Connect "servername"

On Error Resume Next

For Each oDB in oServer.Databases
    WScript.Echo "Database: " & oDB.Name
    oDB.ExecuteImmediate sCmdBatch
Next

Monday, January 03, 2005 3:22:39 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
Comments are closed.
Search

Further Reading...

Powered by: newtelligence dasBlog 2.2.8279.16125

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008, Paul Schaeflein

Send mail to the author(s) E-mail