Warm tip: This article is reproduced from serverfault.com, please click

SQL Insert does column order matter

发布于 2020-11-27 22:06:23

I have two tables with the same field names and a stored procedure that updates table B with Table A's data by doing a delete from current table and insert into current table from another table that has update values in it:

delete from ac.Table1

insert into ac.Table1
    select *
    from  dbo.OriginalTable
    where dtcreate <getdate()-1

I had to recreate Table1 through GIS software which adds GlobalIDs and an Object ID field. The original order had Object ID at the end and the new table has it at the front. Will this impact executing the SQL statement above?

Questioner
geoJshaun
Viewed
11
Hanish Goel 2020-11-28 06:09:57

Yes it will. The order of the columns should match for each value to go in desired column You can try Insert into ac.Table1 (column1....columnN)