create table #tb(item varchar(10),value varchar(10))
insert into #tb
select 'AA','BEIJING'
union all select 'CC','china'
union all select 'KK','TEST'
union all select 'MMMM','SHANG HAI'declare @s varchar(1000)
set @s=''
select @s=@s+','+item+','+value
from #tb
set @s=stuff(@s,1,1,'')
print @s
/*
AA,BEIJING,CC,china,KK,TEST,MMMM,SHANG HAI
*/
insert into #tb
select 'AA','BEIJING'
union all select 'CC','china'
union all select 'KK','TEST'
union all select 'MMMM','SHANG HAI'declare @s varchar(1000)
set @s=''
select @s=@s+','+item+','+value
from #tb
set @s=stuff(@s,1,1,'')
print @s
/*
AA,BEIJING,CC,china,KK,TEST,MMMM,SHANG HAI
*/
2.自己根据需求构建datatable