34,590
社区成员
发帖
与我相关
我的任务
分享
服务器 (2013-01-25 9:12:56)
CREATE TABLE [Table3] (
[test_id] [int] NOT NULL ,
[批文_省级] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[批文_部级] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
insert into Table3
select 1,'s2013001','b2013001'
insert into Table3
select 2,'s2013002','b2013002'
insert into Table3
select 3,'s2013003','b2013004'
select * from table3
where 批文_省级 like '_201300_'
create table #tb
(
name varchar(50) not null,
)
go
insert into #tb(name) values('批文_省级'),('批文_部级')
select name from #tb where name like N'%省%'
name
--------------------------------------------------
批文_省级
(1 行受影响)
where left(字段,charindex('_',字段)-1) like xxx --'-'左边的
and right(字段,len(字段)-charindex('_',字段)) like xxx --'-'右边的