SQL SERVER比较两个表

发布于:2024-05-09 ⋅ 阅读:(27) ⋅ 点赞:(0)

SELECT *
FROM v_u8sync_inv_demand_storage
    FULL OUTER JOIN u8sync_inv_demand_storage
        ON v_u8sync_inv_demand_storage.存货档案_存货编码 = u8sync_inv_demand_storage.存货档案_存货编码
WHERE (
          v_u8sync_inv_demand_storage.存货档案_存货编码 IS NULL
          AND u8sync_inv_demand_storage.存货档案_存货编码 IS NOT NULL
      )
      OR
      (
          v_u8sync_inv_demand_storage.存货档案_存货编码 IS NOT NULL
          AND u8sync_inv_demand_storage.存货档案_存货编码 IS NULL
      )
      OR
      (
          v_u8sync_inv_demand_storage.存货档案_存货编码 IS NOT NULL
          AND u8sync_inv_demand_storage.存货档案_存货编码 IS NOT NULL
          AND
          (
              v_u8sync_inv_demand_storage.存货档案_存货编码 <> u8sync_inv_demand_storage.存货档案_存货编码
              OR v_u8sync_inv_demand_storage.存货档案_存货名称 <> u8sync_inv_demand_storage.存货档案_存货名称
              OR v_u8sync_inv_demand_storage.存货档案_规格型号 <> u8sync_inv_demand_storage.存货档案_规格型号
              OR v_u8sync_inv_demand_storage.存货名称 <> u8sync_inv_demand_storage.存货名称
              OR v_u8sync_inv_demand_storage.规格型号 <> u8sync_inv_demand_storage.规格型号
              OR v_u8sync_inv_demand_storage.库存存货编码 <> u8sync_inv_demand_storage.库存存货编码
              OR v_u8sync_inv_demand_storage.库存存货档案名称 <> u8sync_inv_demand_storage.库存存货档案名称
              OR v_u8sync_inv_demand_storage.库存存货规格型号 <> u8sync_inv_demand_storage.库存存货规格型号
              OR v_u8sync_inv_demand_storage.库存数量 <> u8sync_inv_demand_storage.库存数量
              OR v_u8sync_inv_demand_storage.生产订单存货编码 <> u8sync_inv_demand_storage.生产订单存货编码
              OR v_u8sync_inv_demand_storage.生产订单存货规格型号 <> u8sync_inv_demand_storage.生产订单存货规格型号
              OR v_u8sync_inv_demand_storage.生产订单存货名称 <> u8sync_inv_demand_storage.生产订单存货名称
              OR v_u8sync_inv_demand_storage.生产订单累计入库数量 <> u8sync_inv_demand_storage.生产订单累计入库数量
              OR v_u8sync_inv_demand_storage.生产订单数量 <> u8sync_inv_demand_storage.生产订单数量
              OR v_u8sync_inv_demand_storage.生产订单未入库数量 <> u8sync_inv_demand_storage.生产订单未入库数量
              OR v_u8sync_inv_demand_storage.生产订单未入库数量不能满足生产订单数量 <> u8sync_inv_demand_storage.生产订单未入库数量不能满足生产订单数量
              OR v_u8sync_inv_demand_storage.索物函累计发货数量 <> u8sync_inv_demand_storage.索物函累计发货数量
              OR v_u8sync_inv_demand_storage.索物函累计未发货数量 <> u8sync_inv_demand_storage.索物函累计未发货数量
              OR v_u8sync_inv_demand_storage.索物函累计需求数量 <> u8sync_inv_demand_storage.索物函累计需求数量
              OR v_u8sync_inv_demand_storage.物料编码 <> u8sync_inv_demand_storage.物料编码
          )
      );