日期:2014-05-18 浏览次数:20953 次
CREATE TABLE BBBB
(
idx int,
yea int,
name varchar(20),
qiguan varchar(20)
)
insert into BBBB
select 1,2011,'张三','手' union all
select 2,2012,'李四','脚' union all
select 3,2011,'王五','眼' union all
select 4,2012,'小名','眼手'
select yea,[name],shou=case when patindex(qiguan,'手')>0 then '手' else null end,
jiao=case when patindex(qiguan,'脚')>0 then '脚' else null end,
yan=case when patindex(qiguan,'眼')>0 then '眼' else null end from BBBB
yea name shou jiao yan
----------- -------------------- ---- ---- ----
2011 张三 手 NULL NULL
2012 李四 NULL 脚 NULL
2011 王五 NULL NULL 眼
2012 小名 NULL NULL NULL
(所影响的行数为 4 行)