| Author |
Topic |
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-01-02 : 04:00:03
|
| my table containing like this a 1a 2a 3a 4a 5b 1b 2b 3b 4i want output like thisa 1,2,3,4,5b 1,2,3,4thanks in advance |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-01-02 : 04:31:02
|
| thanks plz tel in simple way |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-02 : 04:35:01
|
quote: Originally posted by raky thanks plz tel in simple way
Where do you want to show data?Which one do you find it difficult?MadhivananFailing to plan is Planning to fail |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-01-02 : 04:42:29
|
| thanks |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-02 : 04:56:14
|
If you are still finding it difficult, one method:-SELECT DISTINCT t1.[name],LEFT(List.t2,LEN(List.t2)-1) AS 'IdList'FROM @sample t1CROSS APPLY (SELECT CAST(name_id AS varchar(5)) + ',' FROM @sample WHERE [name]=t1.[name] FOR XML PATH(''))List(t2) |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-01-02 : 05:56:24
|
| thanks |
 |
|
|
ranganath
Posting Yak Master
209 Posts |
Posted - 2008-01-02 : 07:38:51
|
| Hi,Try This one AlsoDECLARE @StrConcat TABLE (col1 nvarchar(10),col2 nvarchar(10))insert into @StrConcatselect 'db1','host1'union all select 'db1','host2'union all select 'db1','host3'union all select 'db2','host1'union all select 'db2','host2'union all select 'db3','host2'union all select 'db3','host3'select col1, stuff( ( select ','+ col2 from @StrConcat t1 where t2.col1 = t1.col1 for xml path('')),1,1,'') Valfrom @StrConcat t2group by col1order by col1 |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-01-02 : 23:34:26
|
| thank u |
 |
|
|
|