Does INSERT INTO … SELECT … always match fields by ordinal position?

前端 未结 3 607
太阳男子
太阳男子 2021-02-18 16:16

My tests seem to confirm that

INSERT INTO a (x, y) SELECT y, x FROM b

maps b.y to a.x, i.e., the fields are matched o

3条回答
  •  渐次进展
    2021-02-18 16:42

    That is correct, SQL Server does not try to do any mapping of column names since you can apply any aliases to the source data that you like. It will always reference ordinal position.

提交回复
热议问题