Code
-- Create a Test Database
Create Database DB
Go
UseDB
-- Create a test table
Create Table TB (ID Int Identity , Col Ntext , Constraint Pk_tb Primary Key (ID ))
Insert TB Select N ' If nothing happens '
Union All Select N ' Chelaile malong ABCD is too small to lose '
Go
--Initialize full-text index
ExecSp_fulltext_database'Enable'
Go
--Create a full-text directory named Test
ExecSp_fulltext_catalog'Test','Create'
Go
-- Create and fill full-text index
Exec Sp_fulltext_table ' TB ' , ' Create ' , ' Test ' , ' Pk_tb '
Exec Sp_fulltext_column ' TB ' , ' Col ' , ' Add ' , Zero X 0804
Exec Sp_fulltext_table ' TB ' , ' Start_change_tracking '
Exec Sp_fulltext_table ' TB ' , ' Start_background_updateindex '
Go
-- Search data immediately. No data is found.
Select * From TB Where Contains (COL, n ' "ABCD" ' )
Waitfor Delay ' 00:00:01 '
-- Data can be retrieved after delay
Select * From TB Where Contains (COL, n ' "ABCD" ' )
-- Insert a new data entry
Insert TB Select N ' If ABCD has nothing to do with it '
-- No new data can be retrieved.
Select * From TB Where Contains (COL, n ' "ABCD" ' )
Waitfor Delay ' 00:00:15 '
-- Data can be retrieved after delay
Select * From TB Where Contains (COL, n ' "ABCD" ' )
Go
--Delete Test
UseMaster
Drop DatabaseDB