----------------------------------------------------------------
-- Author  :DBA_HuangZJ(发粪涂墙)
-- Date    :2014-04-29 14:05:41
-- Version:
--      Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64) 
-- Apr  2 2010 15:48:46 
-- Copyright (c) Microsoft Corporation
-- Enterprise Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)
--
----------------------------------------------------------------
--> 测试数据[huang]
if object_id('[huang]') is not null drop table [huang]
go 
create table [huang]([AuID] int,[GoodID] int,[ArrValue] VARCHAR(30),[ArrValue2] VARCHAR(30))
insert [huang]
select 1,1,'1549591 1549588 1549590','1550263 12955626 1550283' union all
select 2,1,'1222326 1222336','1222922 1222924' union all
select 3,1,null,NULL union all
select 4,2,'1549592 1549591','1550268 1550263' union all
select 5,2,'1222326','1222895'
--------------生成数据--------------------------
select a.GOODID,
stuff((select ' '+[ArrValue] from [huang] b 
       where b.GOODID=a.GOODID
       for xml path('')),1,1,'') 'ArrValue',
       
stuff((select ' '+[ArrValue2] from [huang] b 
       where b.GOODID=a.GOODID
       for xml path('')),1,1,'') 'ArrValue2'
from [huang] a
group by  a.GOODID
----------------结果----------------------------
/* 
GOODID      ArrValue                                    ArrValue2
----------- ------------------------------------------- --------------------------------------------------
1           1549591 1549588 1549590 1222326 1222336     1550263 12955626 1550283 1222922 1222924
2           1549592 1549591 1222326                     1550268 1550263 1222895
 
*/