| Author |
Topic  |
|
|
praveen050
Starting Member
9 Posts |
Posted - 05/23/2012 : 03:00:40
|
Write a SQL to convert Multiple Records in to Comma Separated values and Insert into Different table Write a sql to load data as comma separated one record per Agent in to T_AGENT_CSVEXT. EX: if TAGENT has Agent_ID Agent_Extension aapena 83601014 aapena 83601014 aapena 83605027 aapena 83605236 aapena 83605473 aapena 83605724
T_AGENT_CSVEXT should have Agent_ID Agent_Extension aapena 83601014,83605027,83605236,83605473,83605724
|
Edited by - praveen050 on 05/23/2012 03:44:58
|
|
|
khtan
In (Som, Ni, Yak)
Singapore
16746 Posts |
Posted - 05/23/2012 : 03:12:11
|
Thank you for posting your assignment question.
Can you also shared with us the solution ?
KH Time is always against us
|
 |
|
|
praveen050
Starting Member
9 Posts |
Posted - 05/23/2012 : 03:14:14
|
| i m not getting the solution |
 |
|
|
khtan
In (Som, Ni, Yak)
Singapore
16746 Posts |
Posted - 05/23/2012 : 03:57:03
|
what have you tried ?
KH Time is always against us
|
 |
|
|
praveen050
Starting Member
9 Posts |
Posted - 05/23/2012 : 09:04:02
|
open tabcur declare @g varchar(1000) fetch tabcur into @g while (@@FETCH_STATUS=0) begin if (@g=@g)
DECLARE @ext varchar(100) SELECT @ext = COALESCE(@ext + ', ', '') + cast(id as varchar) FROM tab where mm=@g print @g +' ' +@ext
fetch tabcur into @g end
and my result
hh 1, 2, 3, 4 hh 1, 2, 3, 4, 1, 2, 3, 4 hh 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 hh 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 gg 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 7 gg 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 7, 5, 6, 7 gg 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 7, 5, 6, 7, 5, 6, 7
but i want hh 1,2,3,4 gg 5,6,7 |
 |
|
|
khtan
In (Som, Ni, Yak)
Singapore
16746 Posts |
|
|
praveen050
Starting Member
9 Posts |
Posted - 05/24/2012 : 02:14:14
|
| Thanks for your suggestion i got the answer, actually i have table with more than 8000 rows |
 |
|
|
khtan
In (Som, Ni, Yak)
Singapore
16746 Posts |
Posted - 05/24/2012 : 02:47:02
|
quote: Originally posted by praveen050
Thanks for your suggestion i got the answer, actually i have table with more than 8000 rows
that will not be an issue.
Just use the SELECT query in that thread
KH Time is always against us
|
 |
|
| |
Topic  |
|
|
|