SQL Server: Data filling in full-text search

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.