INSERT into InvInventoryItem
SELECT
CONVERT (VARCHAR(20),row_number() over (order by t1.ProductKey) + 5176000) 'InventoryItemKey',
t1.ProductKey, t1.WarehouseKey,0,0,0,0,0,0,0,0,0,0,0,0,0,0,GETDATE(),
GETDATE(),-1,-1,0,0,0,0,NULL,NULL,0,0,0,NULL,NULL,NULL,NULL,0,NULL,NULL,0,0,0,NULL,NULL,
NULL,NULL,NULL,0,0
FROM (SELECT ProductKey, WarehouseKey FROM InvProduct
Cross JOIN InvWarehouse) t1
LEFT JOIN InvInventoryItem t2 ON T1.ProductKey = t2.ProductKey and t1.WarehouseKey = t2.WarehouseKey
where t2.InventoryItemKey is null
order by t1.WarehouseKey, t1.ProductKey