BEGIN TRANSACTION

DELETE
FROM tbOrderDeliverySchedule
WHERE VendorId = 10

INSERT INTO tbOrderDeliverySchedule (
	EntityId
	,VendorId
	,OrderDay
	,DeliveryDue
	,CoverUntil
	)
SELECT entityid
	,10
	,1
	,'2019-12-31 03:00:00.000'
	,'2020-01-01 03:00:00.000'
FROM tbEntity
WHERE EntityTypeID = 4
	AND STATUS = 'open'
ORDER BY EntityID

INSERT INTO tbOrderDeliverySchedule (
	EntityId
	,VendorId
	,OrderDay
	,DeliveryDue
	,CoverUntil
	)
SELECT entityid
	,10
	,2
	,'2020-01-01 03:00:00.000'
	,'2020-01-03 03:00:00.000'
FROM tbEntity
WHERE EntityTypeID = 4
	AND STATUS = 'open'
ORDER BY EntityID

SELECT *
FROM tbOrderDeliverySchedule

ROLLBACK
	--COMMIT
