declare @dashu char(4) set @dashu='大树' select * from tb where patindex('%['+@dashu+']%',字段)>0
OMG~~~Fantasy~~ 全部都符合了...
--------------------------------- -- Author: htl258(Tony) -- Date : 2009-07-31 22:23:13 --------------------------------- --> 生成测试数据表:tbIf not object_id('[tb]') is null Drop table [tb] Go Create table [tb]([TEXT] nvarchar(4)) Insert tb Select '一大颗树' union all Select '大中华' union all Select '百年树木' Go --Select * from tb-->SQL查询如下: create function f_getstr(@s nvarchar(200)) returns nvarchar(4000) as begin declare @r nvarchar(4000) while len(@s)>0 begin set @r=isnull(@r+'%','')+left(@s,1) set @s=stuff(@s,1,1,'') end return @r end godeclare @dashu char(4) set @dashu='大树' select * from tb where [TEXT] like '%'+ dbo.f_getstr(@dashu)+'%'/* TEXT ---- 一大颗树(1 行受影响) */
from tb
where charindex('课本',字段名)>0
from tb
where 字段名 like '%课本%'
from tb
where col like '%课本%'
from tb
where patindex('%课本%',字段)>0
from tb
where patindex('%课本%',col)>0
from tb
where 字段名 like '%大%树%'
from tb
where 字段名 like '%大%树%'
--or
select *
from tb
where patindex('%课%本%',字段)>0
怎样%大%树%啊...
from tb
where patindex('%[大树]%',字段)>0
想在列XMmc中相似的数据,就是我说的那种效果
set @dashu='大树'
select *
from tb
where patindex('%['+@dashu+']%',字段)>0
全部都符合了...
---------------------------------
-- Author: htl258(Tony)
-- Date : 2009-07-31 22:23:13
---------------------------------
--> 生成测试数据表:tbIf not object_id('[tb]') is null
Drop table [tb]
Go
Create table [tb]([TEXT] nvarchar(4))
Insert tb
Select '一大颗树' union all
Select '大中华' union all
Select '百年树木'
Go
--Select * from tb-->SQL查询如下:
create function f_getstr(@s nvarchar(200))
returns nvarchar(4000)
as
begin
declare @r nvarchar(4000)
while len(@s)>0
begin
set @r=isnull(@r+'%','')+left(@s,1)
set @s=stuff(@s,1,1,'')
end
return @r
end
godeclare @dashu char(4)
set @dashu='大树'
select *
from tb
where [TEXT] like '%'+ dbo.f_getstr(@dashu)+'%'/*
TEXT
----
一大颗树(1 行受影响)
*/