MSSQL Select From Union

If you want to select something from union join on MSSQL using this:

SELECT id FROM
(
    (SELECT id FROM t1)
    UNION
    (SELECT id FROM t2)
)

Problem is that this construct does not work because of Incorrect syntax near ‘)’ error. Solution is simple:

SELECT id FROM
(
    (SELECT id FROM t1)
    UNION
    (SELECT id FROM t2)
) AS T

Add a comment


Would you like to get top 5 links on C# every Monday?
Sign up to C# Digest and stay up to date!