'Table alias ignored for columns specified in INSERT statement in SQL Server

I saw above question in one of the blogs. But couldn't find the answer anywhere. Maybe SQL Server experts here can help me on this.

CREATE TABLE #DEMO (VALUE1 INT, VALUE2 VARCHAR(10))

CREATE TABLE #DEMO1 (VALUE1 INT, VALUE2 VARCHAR(10))

INSERT INTO #DEMO VALUES (1, '10')

INSERT INTO #DEMO1 (a.a.a.value1,b.b.b.value2)
    SELECT
        Value1, Value2
    FROM #DEMO

If you see the insert statement, I have specified some alias name in the inserted columns. To my wonder, SQL Server didn't throw any error while executing the statement. What's the reason behind this? Could anyone help?



Solution 1:[1]

List of column names in this place is list of names in #DEMO1 table therefore qualifiers doesn't have any meaning and most likely are just ignored.

It is interesting why it doesn't rise syntax error, either way if you would want to use columns names as a.a.a.value1 then you would have to put name in [] or "".

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1