SQL SERVER比较两个表

该篇文章描述了一个SQL查询,用于在IT系统中对比两个存货需求存储表的差异,涉及多个字段如存货编码、名称、规格型号等,以查找不一致或更新的需求信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.物料编码
          )
      );
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值