USP_REVENUECATEGORYCODE_NORMALIZESEQUENCENUMBERS

Used to reset the sequence for table entries in the "Revenue Category" code table.

Parameters

Parameter Parameter Type Mode Description
@CHANGEAGENTID uniqueidentifier IN The ID of the change agent resetting the sequence.

Definition

Copy
/*
Generated by Blackbaud AppFx Platform
Date:  12/17/2008 2:31:40 AM
Assembly Version:  Blackbaud.AppFx.Platform.SqlClr, Version=1.7.1271.0, Culture=neutral, PublicKeyToken=null
Copyright Blackbaud
*/
CREATE procedure dbo.USP_REVENUECATEGORYCODE_NORMALIZESEQUENCENUMBERS
(
@CHANGEAGENTID uniqueidentifier = NULL
)
as

if @CHANGEAGENTID IS NULL
    exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;

with NEWNUMS(ROWNUM, ID) as
(
    select row_number() over(order by SEQUENCE), ID
    from dbo.REVENUECATEGORYCODE
)
update dbo.REVENUECATEGORYCODE
set REVENUECATEGORYCODE.SEQUENCE = NEWNUMS.ROWNUM,
    REVENUECATEGORYCODE.CHANGEDBYID=@CHANGEAGENTID,
    REVENUECATEGORYCODE.DATECHANGED=GETDATE()
from dbo.REVENUECATEGORYCODE
    inner join NEWNUMS
    on REVENUECATEGORYCODE.ID = NEWNUMS.ID;

if @@error<>0 return 1;

return 0;