我有一个表,其中的值如下
FKTABLE_NAME FKCOLUMN_NAME PKCOLUMN_NAME
table1 column1 column1
table1 column2 column2
table2 column1 column1
table2 column2 column2我需要如何将其转换为
FKTABLE_NAME FKCOLUMN_NAME PKCOLUMN_NAME
tablel1 column1,column2 column1,column2
table12 column1,column2 column1,column2基本上,我尝试按表名对逗号分隔的列进行分组。
谢谢
发布于 2011-02-24 00:59:04
与所有字符串聚合问题一样,我建议编写一个自定义聚合(我强烈建议使用clr聚合以获得最佳性能),并编写如下查询
select fktablename, stringAggregate(fkcolumnname), stringAggregate(pkcolumnname)
group by
fktablenamesome tips here
other nice reading
https://stackoverflow.com/questions/5090062
复制相似问题