--创建全文索引
exec sp_fulltext_column 'tb','a','add',0x0804
exec sp_fulltext_column 'tb','b','add',0x0804
go
--插入数据(注意插入数据时,字段类型及N前导符对最终查询结果的影响)
insert tb select '中国营农场', '中国营农场'
union all select N'中国营农场',N'中国营农场'
union all select '中国营农场',N'中国营农场'
union all select N'中国营农场', '中国营农场'
go
--填充全文索引
exec sp_fulltext_table 'tb','start_full'
--填充全文索引后,有一定的延迟时间才会生效,所以要延时
waitfor delay '00:00:10'
go
--查询
select * from tb where contains(a,'"国营"')
select * from tb where contains(b,'"国营"')
select * from tb where contains(a,N'"国营"')
select * from tb where contains(b,N'"国营"')
select * from tb
go
--删除测试
use master
go
drop database test
/*--测试结果
ID a b
----------- ---------- ----------
4 中国营农场 ?????
2 中国营农场 ?????
(所影响的行数为 2 行)
ID a b
----------- ---------- ----------
(所影响的行数为 0 行)
ID a b
----------- ---------- ----------
4 中国营农场 ?????
2 中国营农场 ?????