Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
karthickbabu
Posting Yak Master
151 Posts |
Posted - 2009-05-14 : 00:36:14
|
My Tables values are like theseA1 AA A1 ABA1 ACA2 BAA2 BBA3 CAI need output like as belowA1 AAABACA2 BABBA3 CA==================================================== you realize you've made a mistake, take immediate steps to correct it. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-05-14 : 02:27:32
|
declare @temp table ( Id varchar(30), Val varchar(30))insert into @tempselect 'A1', 'AA' union allselect 'A1', 'AB' union allselect 'A1', 'AC' union allselect 'A2', 'BA' union allselect 'A2', 'BB' union allselect 'A3' ,'CA'select distinct id ,stuff( (select ''+val from @temp where id = t.id for xml path('')),1,0,'') as val from @temp t |
|
|
karthickbabu
Posting Yak Master
151 Posts |
Posted - 2009-05-14 : 02:44:38
|
Thanks for your link==================================================== you realize you've made a mistake, take immediate steps to correct it. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-05-14 : 02:47:45
|
quote: Originally posted by raky declare @temp table ( Id varchar(30), Val varchar(30))insert into @tempselect 'A1', 'AA' union allselect 'A1', 'AB' union allselect 'A1', 'AC' union allselect 'A2', 'BA' union allselect 'A2', 'BB' union allselect 'A3' ,'CA'select distinct id ,stuff( (select ''+val from @temp where id = t.id for xml path('')),1,0,'') as val from @temp t
This wont work in SQL Server 2000MadhivananFailing to plan is Planning to fail |
|
|
|
|
|
|
|