UFN_DISCOUNTGROUPSIZE_UNIQUESIZECHECK
Checks to insure duplicate group sizes are not added to discounts
Return
| Return Type |
|---|
| bit |
Parameters
| Parameter | Parameter Type | Mode | Description |
|---|---|---|---|
| @DISCOUNTID | uniqueidentifier | IN | |
| @GROUPSIZE | int | IN |
Definition
Copy
create function dbo.UFN_DISCOUNTGROUPSIZE_UNIQUESIZECHECK
(
@DISCOUNTID uniqueidentifier,
@GROUPSIZE int
)
returns bit
with execute as caller
as begin
declare @GROUPSIZECOUNT int;
declare @UNIQUEGROUPSIZECOUNT int;
select
@GROUPSIZECOUNT = count([GROUPSIZE])
from dbo.[GROUPSIZEDISCOUNT]
where [DISCOUNTID] = @DISCOUNTID;
select
@UNIQUEGROUPSIZECOUNT = count(distinct [GROUPSIZE])
from dbo.[GROUPSIZEDISCOUNT]
where [DISCOUNTID] = @DISCOUNTID;
if @GROUPSIZECOUNT = @UNIQUEGROUPSIZECOUNT
return 1; --good to go
return 0;
end