Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Insert one table into another

I have two near identical tables (without PK I believe), each has slightly different data in, but in the same format.

How do I insert all the data from one table onto the end of the other table? Thus creating one giant table.

Each table has millions of rows.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have been trying various combinations of INSERT INTO os5birm SELECT * FROM os50birm but I get the following error message:

Msg 213, Level 16, State 1, Line 1
Column name or number of supplied values does not match table definition.

The two tables are formatted as follows:

enter image description here

And the data inside is as follows:

enter image description here

Cheers!

>Solution :

Your issue is that you are trying to insert the computed value ogr_geometry into the computed column of the same name, and you can’t insert into computed columns. The solution, which you should really be doing anyway (Bad Habits to Kick : Using SELECT * / omitting the column list) is to explicitly list the columns you are selecting, and the columns you are inserting to:

INSERT INTO os5birm (Column1, Column2, Column3) 
SELECT Column1, Column2, Column3 
FROM os50birm;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading