
[dbo].[BcImportDimensions]
create procedure [dbo].[BcImportDimensions]
@items BcDimensionImportItems readonly
as
begin
set nocount on
declare @now datetimeoffset = sysdatetimeoffset();
;with ImportData as
(
select
BcId,
LastModified,
Code,
[Description]
from @items Items
)
merge BcDimension with (tablock) using ImportData on
BcDimension.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,
Code,
[Description],
LastImportedOn,
CreatedOn,
LastUpdatedInBcOn
)
values
(
ImportData.BcId,
ImportData.Code,
ImportData.[Description],
@now,
@now,
ImportData.LastModified
)
;
end
GO
GRANT EXECUTE ON [dbo].[BcImportDimensions] TO [MssExec]
GO