select sname from student where Sname like N'[吖-做][吖-做][吖-做]'这样查
select * from student where len(sname) = 3 select * from student where len(cast(sname as varchar)) = 3
因为有空格的缘故 where rtrim(ltrim(Sname))like '___'
where rtrim(ltrim(Sname))like '___'
select sname from student where Sname like N'[吖-咗][吖-咗][吖-咗]'改为这样,以前总结的一个错误,差点忘了http://blog.csdn.net/htl258/archive/2009/09/21/4571814.aspx
create table tb(name nchar(3)) insert into tb select '楼' union all select '楼主' union all select '楼主好'select * from tb where name like '___'--结果 /* 楼 楼主 楼主好 */drop table tb; select * from tb create table tb(name nvarchar(3)) insert into tb select '楼' union all select '楼主' union all select '楼主好'select * from tb where name like '___'--结果 /* 楼主好 */
where Sname like N'[吖-做][吖-做][吖-做]'这样查
select * from student where len(cast(sname as varchar)) = 3
where rtrim(ltrim(Sname))like '___'
where Sname like N'[吖-咗][吖-咗][吖-咗]'改为这样,以前总结的一个错误,差点忘了http://blog.csdn.net/htl258/archive/2009/09/21/4571814.aspx
create table tb(name nchar(3))
insert into tb
select '楼' union all
select '楼主' union all
select '楼主好'select * from tb where name like '___'--结果
/*
楼
楼主
楼主好
*/drop table tb;
select * from tb
create table tb(name nvarchar(3))
insert into tb
select '楼' union all
select '楼主' union all
select '楼主好'select * from tb where name like '___'--结果
/*
楼主好
*/