I have tblAgenda and tblMeeting.
I want to have all agenda notes from Agenda Daily Note column of tblAgenda into Agenda Column which needs to be computed column on tblMeeting.
| tblMeeting | |||
| ID | Agenda | ||
| 1 | |||
| tblAgenda | |||
| AgendaID | MeetingID | Day | Agenda daiy Note |
| 1 | 1 | 1 | This Is day 1, First agenda. |
| 2 | 1 | 1 | This Is day 1, Second agenda. |
| 3 | 1 | 2 | This Is day 2,First agenda. |
| 4 | 1 | 2 | This Is day 2 , Second agenda. |
| 5 | 1 | 2 | This Is day 2, Third agenda. |
How do i achieve this?
Nepethya RanaPosted Sep 25, 2017, 3:50 PM
RETURNS varchar(max)
AS
-- Returns the stock level for the product.
BEGIN
DECLARE @Agenda varchar(max);
SELECT @Agenda =stuff( (SELECT ','+ [Agenda daiy Note]
FROM tblAgenda a2
WHERE a2.MeetingID = a1.MeetingID
FOR XML PATH(''), TYPE).value('.', 'varchar(max)')
,1,1,'')
FROM tblAgenda a1
GROUP BY MeetingID having MeetingID=@MeetingID;
RETURN @Agenda;
END;
Zakir AhamedPosted Sep 23, 2017, 12:51 AM