USP_SIMPLEDATALIST_TERM_NAMECODE
Simple list of terms.
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@SESSIONNAMECODEID | uniqueidentifier | IN | Session |
Definition
Copy
CREATE procedure dbo.USP_SIMPLEDATALIST_TERM_NAMECODE
(
@SESSIONNAMECODEID uniqueidentifier = null
)
as
select
T.VALUE,
T.LABEL
from
(select
TERMNAMECODE.ID as VALUE,
TERMNAMECODE.DESCRIPTION as LABEL,
TERM.STARTDATE,
ROW_NUMBER() over (partition by TERMNAMECODE.ID order by TERM.STARTDATE) as ROW
from dbo.SESSION
inner join dbo.TERM on SESSION.ID = TERM.SESSIONID
inner join dbo.TERMNAMECODE on TERM.TERMNAMECODEID = TERMNAMECODE.ID
where (
@SESSIONNAMECODEID is null or
@SESSIONNAMECODEID = '00000000-0000-0000-0000-000000000000' or
dbo.SESSION.SESSIONNAMECODEID = @SESSIONNAMECODEID
)) T
where T.ROW = 1
order by T.STARTDATE