[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 580: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 636: sizeof(): Parameter must be an array or an object that implements Countable
Unofficial UNIT-e Forum • TVF_StudentEnrolmentCreateDate
Page 1 of 1

TVF_StudentEnrolmentCreateDate

Posted: Thu Mar 02, 2017 11:57 pm
by robinwilson16
Displays the created date of the specified enrolment using the audit data

Code: Select all

CREATE FUNCTION [dbo].[TVF_StudentEnrolmentCreateDate] (
	@Session VARCHAR(7), 
	@StudentEnrolmentID numeric(16, 0)
)
RETURNS TABLE
AS
RETURN 
	/*
	DECLARE @Session NVARCHAR(7) = '2015-16'
	DECLARE @StudentEnrolmentID numeric(16, 0) = 727000003893609
	DECLARE @Property VARCHAR(20) = 'status'
	DECLARE @DateChanged DateTime = '2016-06-01'
	*/
	--6

	SELECT
		Value = MIN ( SAT.sat_start )
	FROM ulive.dbo.capd_moduleenrolment ME
	LEFT JOIN ulive.dbo.CAPS_SYSTEM_AUDIT_TRAIL SAT
		ON SAT.sat_id = ME.e_id	
	WHERE	
		ME.e_id	= @StudentEnrolmentID