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 |
aiman
Starting Member
18 Posts |
Posted - 2007-06-21 : 14:07:14
|
Suppose I have a Table where Data are inserted like this wayUnID QUERY1011 VASINFO1012 TEXINFO1013 GENERAL QUERY1013 BILL INFO1014 FNF INFO1014 NETWORK PROB1014 TEST CALLNow I want to write a quary which will show this data like UnID QUERY1011 VASINFO1012 TEXINFO1013 GENERAL QUERY,BILL INFO1014 FNF INFO,NETWORK PROB,TEST CALL1015 SIM DeActivate1016 TEST CALLand so on...PLEASE Help me ASAP....AIMAN |
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-06-21 : 14:39:25
|
If its not doable at the front end, you could create a function that takes in the UnID value and returns a concatenated list of Query values. Call the function in your SELECT. Caution. doing this on a huge dataset can cause performance issues. Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
aiman
Starting Member
18 Posts |
Posted - 2007-06-21 : 14:52:43
|
Please give me a demo script. I will be very pleased if you give me it. I need it very urgent ly |
 |
|
pbguy
Constraint Violating Yak Guru
319 Posts |
Posted - 2007-06-22 : 00:28:47
|
Create table tii (UnID int,QUERY varchar(50))Insert tii Select 1011, 'VASINFO' union allSelect 1012, 'TEXINFO' union allSelect 1013, 'GENERAL QUERY' union allSelect 1013, 'BILL INFO' union allSelect 1014, 'FNF INFO' union allSelect 1014, 'NETWORK PROB' union allSelect 1014, 'TEST CALL'Create function fn_concat(@id int)returns varchar(200)begin Declare @concat varchar(200) Select @concat = Coalesce(@concat+',', '') + QUERY from tii where UnID = @id Return @concatEndSelect distinct UnID, dbo.fn_concat(UnID) From tii--------------------------------------------------S.Ahamed |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
aiman
Starting Member
18 Posts |
Posted - 2007-06-22 : 13:08:03
|
Thank you lots... Really it will be healfull for me..... |
 |
|
|
|
|
|
|