日期:2014-05-17 浏览次数:20500 次
select * from 表 where 字段='Tb23456'
select * from 表 where left(字段,2) = 'Tb'
select * from [表名]
where patindex('tb%',[字段])>0 and
patindex('tbs%',[字段]) =0
----------------------------------------------------------------
-- Author :DBA_Huangzj(發糞塗牆)
-- Date :2013-11-28 11:30:45
-- Version:
-- Microsoft SQL Server 2012 (SP1) - 11.0.3128.0 (X64)
-- Dec 28 2012 20:23:12
-- Copyright (c) Microsoft Corporation
-- Enterprise Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: )
--
----------------------------------------------------------------
--> 测试数据:[huang]
if object_id('[huang]') is not null drop table [huang]
go
create table [huang]([a] varchar(10))
insert [huang]
select 'Tb23456' union all
select 'TBS123456' union ALL
select 'tasd1234' union all
select 'DFS1243456'
--------------开始查询--------------------------
select * from [huang] WHERE a LIKE 'tb[0-9]%'
----------------结果----------------------------
/*
a
----------
Tb23456
*/