日期:2014-05-18 浏览次数:20587 次
-->>>生成测试数据
go
if OBJECT_ID('test')is not null
drop table test
go
create table test(
companyname varchar(50)
)
go
insert test
select '厦门汇源进出口有限公司' union all
select '厦门跃龙机电进出口有限公司' union all
select '厦门非金属矿进出口有限公司' union all
select '厦门国贸控股建设开发有限公司' union all
select '厦门象屿物流集团有限责任公司' union all
select '厦门环华有限公司'
go
if OBJECT_ID('tbl')is not null
drop table tbl
go
create table tbl(
briefname varchar(50)
)
go
insert tbl
select '厦门汇源' union all
select '厦门跃龙' union all
select '厦门物流' union all
select '厦门环华'
select * from test,tbl where CHARINDEX(briefname,companyname)>0
/*
companyname briefname
厦门汇源进出口有限公司 厦门汇源
厦门跃龙机电进出口有限公司 厦门跃龙
厦门环华有限公司 厦门环华
*/
select companyname from test,tbl where CHARINDEX(briefname,companyname)>0
/*
companyname
厦门汇源进出口有限公司
厦门跃龙机电进出口有限公司
厦门环华有限公司
*/