TVF_ActivityLecturers

The list of table valued functions used by Guildford College Reports and any anyone else wishes to share
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
User avatar
robinwilson16
Site Admin
Posts: 185
Joined: Sun Oct 16, 2016 6:46 pm
Forename: Robin
Surname: Wilson
College Name: FEA
Position: MIS Consultant
LinkedIn Profile: https://www.linkedin.com/in/robinwilson16
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

TVF_ActivityLecturers

Post by robinwilson16 » Thu Mar 02, 2017 10:29 pm

Returns the staff attached to an activity as a single comma separated list

Code: Select all

CREATE FUNCTION [dbo].[TVF_ActivityLecturers] (
	@ActivityID numeric(16, 0)
)
RETURNS TABLE
AS
RETURN

SELECT
/*Used in student timetables - ProMonitor, ProPortal, Moodle & student dashboard*/
	Value = 
		STUFF (
			(
				SELECT DISTINCT
					', '+P.p_forenames+' '+P.p_surname
				FROM ulive.dbo.capd_activity AS A2 WITH (nolock) LEFT OUTER JOIN
					 ulive.dbo.capd_staffactivity AS SA WITH (nolock) ON A2.a_id = SA.sa_activity LEFT OUTER JOIN 
					 ulive.dbo.capd_person AS P WITH (nolock) ON SA.sa_activitystaff = P.p_id
				WHERE A2.a_id=A.a_id
				ORDER BY ', '+P.p_forenames+' '+P.p_surname FOR XML PATH (''),TYPE).value('.','varchar(max)') ,1,2, '')
		FROM [UNIT-ESQL\ULIVE].ulive.dbo.capd_activity AS A
		WHERE A.a_id=@ActivityID
		GROUP BY A.a_id

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 1 guest