将具有几何列的两个表连接成一个

时间:2014-01-17 14:47:35

标签: sql sql-server tsql

我有两张完全相同的桌子。我想将它们连接成一个大型数据集。我只是尝试了SELECT-INTO查询,但收到了错误...

SELECT * INTO dbo.ParkingBay 
FROM (SELECT * FROM dbo.ParkingBay_Old 
      UNION 
      SELECT * FROM dbo.ParkingBay_New) AS PARKING_BAY;

错误是:

  

几何数据类型不能选为DISTINCT,因为它是   没有可比性。

2 个答案:

答案 0 :(得分:2)

UNION对组合结果集执行DISTINCT。

UNION ALL消除了这个DISTINCT步骤,但会在结果中产生欺骗的可能性。

如果您对可能性有所了解,那么试试这个

SELECT * INTO dbo.ParkingBay 
FROM (SELECT * FROM dbo.ParkingBay_Old 
      UNION ALL
      SELECT * FROM dbo.ParkingBay_New) AS PARKING_BAY;

答案 1 :(得分:1)

看起来ALL解决了所有问题:

SELECT * INTO dbo.ParkingBay 
FROM (SELECT * FROM dbo.ParkingBay_Old 
      UNION ALL
      SELECT * FROM dbo.ParkingBay_New) AS PARKING_BAY;