0
如何在SQL Server中使行数据逗号分隔?如何在SQL Server中将行数据逗号分隔
CREATE TABLE CountryState
(Country Varchar(15), State Varchar(15))
GO
INSERT INTO CountryState VALUES('India','MH')
INSERT INTO CountryState VALUES('India','DL')
INSERT INTO CountryState VALUES('US','NJ')
INSERT INTO CountryState VALUES('US','NY')
GO
SELECT * FROM CountryState
输出:
Country State
----------------------------
India MH
India DL
US NJ
US NY
我需要在以下格式输出。
Country State
------------------
India MH,DL
US NJ,NY
或http://stackoverflow.com/questions/8868604/sql-group-concat-function-in-sql-server ... – a1ex07