I have 2 tables with duplicate record including 'Id' field, and I need union them.
But I think [union all] is much more efficient than [union]
for the reason that it need not sorting.
Following is my sql:
SELECT *
FROM [dbo].[RealTime]
UNION ALL
SELECT *
FROM [dbo].[Query] a
WHERE NOT EXISTS(
SELECT TOP 1 1
FROM [dbo].[RealTime] b
WHERE a.Id = b.Id
)
Will you have any suggestion or more elegant statement ?