• dan-572483 (1/2/2013)


    If all the queries in combined by the UNION statement are quering the same table (or differenet tables but the coumn names are the same), then you shoudn't need to use AS <header>, correct?

    You don't need the AS header in SQL Server at all. SQL gets the result column names from the first query in a UNION. The others can have different column names -- or no column names at all.

    SELECT 1 AS a, 2 AS b

    union all

    select 3 as c, 4 as d

    union all

    select 5 as e, 6 as f

    union all

    select 7, 8

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.