UFN_SPROPPAGERANGE_ISUNIQUE
Validates whether the age ranges are unique and do not overlap
Return
Return Type |
---|
bit |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@MINAGE | tinyint | IN | |
@MAXAGE | tinyint | IN |
Definition
Copy
create function dbo.UFN_SPROPPAGERANGE_ISUNIQUE
(
@MINAGE tinyint,
@MAXAGE tinyint
)
returns bit
with execute as caller
as begin
declare @DUPLICATECOUNT int;
select
@DUPLICATECOUNT = count(*)
from
dbo.SPONSORSHIPOPPORTUNITYAGERANGE
where
(
( MAXAGE between @MINAGE and @MAXAGE) or
(@MAXAGE between MINAGE and MAXAGE) or
( MINAGE between @MINAGE and @MAXAGE) or
(@MINAGE between MINAGE and MAXAGE)
);
if (@DUPLICATECOUNT <= 1)
return 1;
return 0;
end