I wanted to do an insert into with a union, and someone suggested this:
SELECT x INTO ##temp
FROM (SELECT x FROM y UNION ALL SELECT x FROM z) UN
It works, but what is the UN
? Unfortunately, Googling for "t-sql un" isn't very helpful :p
Note: I found out that you can just do SELECT x INTO ##temp FROM y UNION ALL SELECT x FROM b
but I'm still curious about UN
.
EDIT: Ok, so it's an alias, but why is it required to make this work? If I remove it, it won't execute.