SQL Server 通配符为目标字符的查找

create table t(x int identity(1,1) primary key,v nvarchar(32));
go

insert into t(v) values('this is % line'),('this is 1 line');

 

我们的目标是找到'this is % line' 这一行。

select x,v from t where v like'%\%%' escape '\';

第一个'%'用来匹配%前的串。

第二个'%'用来匹配串中的%。

第三个'%'用来匹配%后的串。

escape 指定用来转义的字符。

posted on 2015-02-23 23:08  蒋乐兴的技术随笔  阅读(147)  评论(0)    收藏  举报

导航