Stored Procedures [dbo].[BcImportDimensionValues]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@itemsBcDimensionValueImportItemsmax
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
create procedure [dbo].[BcImportDimensionValues]
    @items BcDimensionValueImportItems readonly
as
begin
set nocount on

    declare @now datetimeoffset = sysdatetimeoffset();

    ;with ImportData as
    (
        select
            Items.BcId,
            Items.LastModified,
            Items.Code,
            Items.[Description],
            --DimensionBcId
            BcDimension.BcDimensionId
        from @items Items
        inner join BcDimension on Items.DimensionBcId = BcDimension.BcId
    )
    merge BcDimensionValue with (tablock) using ImportData on
        BcDimensionValue.BcId = ImportData.BcId
    when matched then update set
        Code = ImportData.Code,
        [Description] = ImportData.[Description],
        LastImportedOn = @now,
        LastUpdatedInBcOn = ImportData.LastModified
    when not matched then insert
    (
        BcId,
        BcDimensionFid,
        Code,
        [Description],
        LastImportedOn,
        CreatedOn,
        LastUpdatedInBcOn
    )
    values
    (
        ImportData.BcId,
        ImportData.BcDimensionId,
        ImportData.Code,
        ImportData.[Description],
        @now,
        @now,
        ImportData.LastModified
    )
    ;


    --BCTD: Hiding support????
end
GO
GRANT EXECUTE ON  [dbo].[BcImportDimensionValues] TO [MssExec]
GO
Uses