MS SQL UNION ALL Deyimi

Aynı kolonlara sahip farklı sunucu, farklı veritabanı, farklı tablo veya farklı sorgular sonucu gelen verileri tek bir sonuçta birleştirmek için UNION ALL kullanabilirsiniz.

SELECT * FROM
(SELECT VW_ORGU_ONAY_CONF.MATERIAL, VW_ORGU_ONAY_CONF.VOPTIONS, VW_ORGU_ONAY_CONF.PROJECT,
VW_ORGU_ONAY_CONF.OUTPUT, VW_ORGU_ONAY_CONF.POTYPE, VW_ORGU_ONAY_CONF.PRDORDER,
VW_ORGU_ONAY_CONF.CONFIRMATION, VW_ORGU_ONAY_CONF.CONFIRMPOS, VW_ORGU_ONAY_CONF.CONFIRMDATE,
VW_ORGU_ONAY_CONF.WORKCENTER, VW_ORGU_ONAY_CONF.CREATEDBY
FROM MACELLAN.dbo.VW_ORGU_ONAY_CONF VW_ORGU_ONAY_CONF WHERE CONFIRMDATE>=’2011-01-01′
UNION ALL
SELECT VW_ORGU_ONAY_CONF.MATERIAL, VW_ORGU_ONAY_CONF.VOPTIONS, VW_ORGU_ONAY_CONF.PROJECT,
VW_ORGU_ONAY_CONF.OUTPUT, VW_ORGU_ONAY_CONF.POTYPE, VW_ORGU_ONAY_CONF.PRDORDER,
VW_ORGU_ONAY_CONF.CONFIRMATION, VW_ORGU_ONAY_CONF.CONFIRMPOS, VW_ORGU_ONAY_CONF.CONFIRMDATE,
VW_ORGU_ONAY_CONF.WORKCENTER, VW_ORGU_ONAY_CONF.CREATEDBY
FROM MAC2011.dbo.VW_ORGU_ONAY_CONF VW_ORGU_ONAY_CONF WHERE CONFIRMDATE>=’2011-01-01′
UNION ALL
SELECT VW_ORGU_ONAY_CONF.MATERIAL, VW_ORGU_ONAY_CONF.VOPTIONS, VW_ORGU_ONAY_CONF.PROJECT,
VW_ORGU_ONAY_CONF.OUTPUT, VW_ORGU_ONAY_CONF.POTYPE, VW_ORGU_ONAY_CONF.PRDORDER,
VW_ORGU_ONAY_CONF.CONFIRMATION, VW_ORGU_ONAY_CONF.CONFIRMPOS, VW_ORGU_ONAY_CONF.CONFIRMDATE,
VW_ORGU_ONAY_CONF.WORKCENTER, VW_ORGU_ONAY_CONF.CREATEDBY
FROM MAC2010.dbo.VW_ORGU_ONAY_CONF VW_ORGU_ONAY_CONF) AS BIRTLESIKTABLO