日期:2014-05-18 浏览次数:20655 次
create table tb(BH varchar(10)) insert into tb values('1H2101') insert into tb values('1H2102') insert into tb values('1H2103') insert into tb values('1HA101') insert into tb values('1HB101') insert into tb values('1HC101') go declare @bh as varchar(10) set @bh = '1H' select * from tb where left(bh,len(@bh)) = @bh and substring(bh , len(@bh)+1 , 1) not between 'A' and 'Z' /* BH ---------- 1H2101 1H2102 1H2103 (所影响的行数为 3 行) */ set @bh = '1H2101' select * from tb where left(bh,len(@bh)) = @bh and substring(bh , len(@bh)+1 , 1) not between 'A' and 'Z' /* BH ---------- 1H2101 (所影响的行数为 1 行) */ drop table tb