narasiman rao

narasiman rao

  • NA
  • 519
  • 746.2k

i worked lot but i coluld not the correct output

Aug 25 2014 8:59 AM
 
 My Query as follows

select Faculty,STUFF(
(select ','+ ltrim(rtrim([Course])) +'-S'+ltrim(rtrim([Session])) from Tb_Sch_Time_Table sch
where sch.Schdate = sch1.Schdate and sch.Faculty = sch1.Faculty
FOR XML PATH(''))
,1,1,'')+')' as Schedule from Tb_Sch_Time_Table sch1
group by schdate,Faculty


I put the above query in view as follows

select distinct faculty,
stuff((select ',' + schedule as Msg from Vw_Presea_Sch_Send_SMS vw1 where vw1.faculty = vw2.faculty FOR XML PATH('')),1,6,'') as msg
from Vw_Presea_Sch_Send_SMS vw2

Views name is Vw_Presea_Sch_Send_SMS

When i execute the above query output as follows
Aug 26 (B Tech 1-S3,B Tech 1-S4)</Msg><Msg>,Aug 28 (ETO-S3,ETO-S4)</Msg>

But i want the correct output as follows
Aug 26 (B Tech 1-S3,B Tech 1-S4) Aug 28 (ETO-S3,ETO-S4)

for that getting a above output what changes i have to made in above query. 

Answers (2)