sql 某一列串联显示
时间:2011-01-17 来源:我是流氓
- create table order_car
- (
- column2 int null,
- column1 varchar(500) null
- )
- insert into order_car(column1,column2)
- values
- (
- '43243' , 3
- )
- insert into order_car(column1,column2)
- values
- (
- 'erew' , 2
- )
- insert into order_car(column1,column2)
- values
- (
- 'gg' , 1
- )
- insert into order_car(column1,column2)
- values
- (
- 'kk' , 1
- )
- select column2, stuff((select ','+ltrim(column1) from order_car
- where column2=b.column2 for xml path('')),1,1,'') from order_car b
以上为google结果,源地址:http://www.bitscn.com/pdb/mssql/201010/191096.html
相关阅读 更多 +