日期:2014-05-18 浏览次数:20474 次
if object_id('[A]') is not null drop table [A] go create table [A]([xh] int,[lx] int,[mc] varchar(2)) insert [A] select 1,1,'谢' union all select 1,2,'谢' union all select 1,3,'高' union all select 1,4,'手' union all select 2,1,'不' union all select 2,2,'吝' union all select 2,3,'赐' union all select 2,4,'教' go select xh, mc=(select ''+mc from A where xh=t.xh for xml path('')) from A t group by xh /** xh mc ----------- ----------------------- 1 谢谢高手 2 不吝赐教 (2 行受影响) **/