I am having an issue similar to the one described here:
How do I force a refresh of a fulltext index within a transaction in mssql?
However, the recommended solution posted there does not work. I tried posting a follow up to the same thread, but it was deleted by a moderator. So I am starting a new question.
Similar to the original query I am also attempting to implement a unit test within a transaction. I would like to insert data into a full text indexed column, query the data to check its validity, and then roll back the insert afterward.
The problem is that the index does not seem to update until after I have committed the transaction. I have tried "WAITFOR DELAY" approach, but no matter how long I wait the index does not update until after the transaction is committed.
Here's a sample of what I'm trying to do:
BEGIN TRAN
INSERT INTO AMMS.Content
(
ContentTypeId,
Name,
ImportDate,
IsDeleted,
LastModifiedBy,
LastModifiedAt,
DisplayInPortal,
StatusId
)
VALUES
(
4,
'my unit test content',
GETUTCDATE(),
0,
1,
GETUTCDATE(),
1,
2
)
declare @count int
set @count = 0
while @count < 10
begin
SELECT FULLTEXTCATALOGPROPERTY('PRIMARY', 'PopulateStatus') AS Status
select * from amms.Content where contains(Name, 'unit')
waitfor delay '00:00:01'
set @count = @count + 1
end
The populate status stays at 9 and the select returns no rows as long as the transaction is pending. Once I commit the populate status returns 0 and the select returns a single row as expected.
Am I missing something? Is there another way to accomplish this? Is this behavior different under different versions of SQL Server? (I'm currently testing using 2008)