Wednesday 18 August 2010

Full-text indexing problems

I ran into a problem recently setting up full-text indexing on a test version of a database, cloned from a production database schema. The initial problem was that the original index was on a drive letter that didn't exist on the target machine. After sorting that out, which involved a little bit of system table manipulation, I then ran into another problem trying to rebuild the indexes. I got as far as a stored procedure call like this:

exec sp_fulltext_table N'[dbo].[credit]', N'create', N'exp_main', N'PK_credit'

which gave:

Server: Msg 2526, Level 16, State 3, Procedure sp_fulltext_table, Line 122
Incorrect DBCC statement. Check the documentation for the correct DBCC syntax and options.


I followed the advice described here:

http://www.eggheadcafe.com/forumarchives/SQLServerfulltext/Aug2005/post23469255.asp

In particular, manually reinstalling the MSSearch / full text search facility as described here:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;827449

... however, it still didn't work.

The issue was resolved when I realised it was something to do with the sp_fulltext_table procedure. In the course of my messing about, it had lost it's "system" attribute - see:

http://www.informit.com/articles/article.aspx?p=25288&seqNum=6

As mentioned here, "DBCC CALLFULLTEXT" needs this to be set to work properly.

Sure enough looking at master.dbo.sysobjects.status for sp_fulltext_table gave
1610612737, which is 0x60000001. This isn't really documented in any detail anywhere, but I found from some more messing about and looking at the source text of the sp_MS_marksystemobject procedure, I found that it actually sets the top two bits in the status field (i.e. 0xC0000000) - so I ran:

sp_MS_marksystemobject 'sp_fulltext_table'

and it all started working.