Stored Procedures [dbo].[XLedgerImportAccountingPeriodRange]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@fromDatedate3
@toDatedate3
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
/*
*    Description: Imports XLedger data into the XLedgerImportAccountingPeriodRange table.
*    
*    This is a single row table that never has any row except XLedgerAccountingPeriodRangeId = 1.
*/

create procedure [dbo].[XLedgerImportAccountingPeriodRange]
    @fromDate date,
    @toDate date
as
begin
    set nocount on

    ;with Items as
    (
        select
            Id = 1,        -- The only PriKey value that is permitted on this table.
            FromDate = @fromDate,
            ToDate = @toDate
    )

    merge XLedgerAccountingPeriodRange with (tablock)
        using Items on Items.Id = XLedgerAccountingPeriodRange.XLedgerAccountingPeriodRangeId
    when not matched then
        insert(
            [XLedgerAccountingPeriodRangeId],
            [FromDate],
            [ToDate]
        )
        values(
            Items.Id,
            Items.FromDate,
            Items.ToDate
        )
    when matched then
        update set
            [FromDate] = Items.FromDate,
            [ToDate] = Items.ToDate
    ;
end
GO
GRANT EXECUTE ON  [dbo].[XLedgerImportAccountingPeriodRange] TO [MssExec]
GO
Uses