UFN_TRANSLATIONTABLEGRADE_SCORESOVERLAP
Check that grade scores do not overlap.
Return
Return Type |
---|
bit |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@TRANSLATIONTABLEID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_TRANSLATIONTABLEGRADE_SCORESOVERLAP
(
@TRANSLATIONTABLEID uniqueidentifier
)
returns bit
as begin
-- Assume scores do not overlap
declare @RETVAL int = 0;
if (exists (select *
from dbo.TRANSLATIONTABLEGRADE ttg
left outer join dbo.TRANSLATIONTABLEGRADE ttg2 on ttg.TRANSLATIONTABLEID = ttg2.TRANSLATIONTABLEID
where ttg.TRANSLATIONTABLEID = @TRANSLATIONTABLEID
--make sure same translation table, but different grade
and ttg.ID <> ttg2.ID
--Need to allow multiple rows that have no scores, so only check against rows that have scores
and ttg.HIGHESTSCORE > 0 and ttg2.HIGHESTSCORE > 0
and ((ttg2.HIGHESTSCORE between ttg.LOWESTSCORE and ttg.HIGHESTSCORE)
or (ttg2.LOWESTSCORE between ttg.LOWESTSCORE and ttg.HIGHESTSCORE))
))
set @RETVAL = 1;
return @RETVAL;
end