declare @mytable TABLE (Col1 VARCHAR(10))
INSERT
INTO @mytable VALUES
(
'AA'
)
,
(
'BB'
)
,
(
'CC'
)
DECLARE @Colstring VARCHAR
(
50
)
SELECT @Colstring = ISNULL(@Colstring + ',' , '' ) + ISNULL( Col1 , '' )
FROM @mytable
SELECT @Colstring AS Colstring
摘自:http://www.cnblogs.com/changbluesky/archive/2010/06/10/1753036.html