日期:2014-05-17 浏览次数:20396 次
---使用Except方法没有就插入,具体代码如下
WITH CTE_SYS AS
(
SELECT
[WarehouseID]
,[WarehouseName]
,[WarehouseArea]
,[ShopBelongTo]
FROM tbl_MetaData_Warehouse
UNION ALL
SELECT
'未知' as [WarehouseID]
,'未知' as [WarehouseName]
,'未知' as [WarehouseArea]
,'未知' as [ShopBelongTo]
),CTE_EXCEPT AS
(
SELECT * FROM CTE_SYS
EXCEPT
SELECT * FROM DataWarehouse.dbo.Dim_Warehouse
)
INSERT INTO DataWarehouse.dbo.Dim_Warehouse
SELECT * FROM CTE_EXCEPT