Thursday, July 31, 2014

Problem of Uncertain no. of columns

Use the full INSERT syntax:



INSERT INTO TABLE (Column1, Column2, Column3)

This allows you to tell the table where to put the data you're sending it, even when the result does not contain the same number of columns as the table.


To be frank you should ALWAYS insert like this, it makes it so much easier when you have to come back and revisit the script, and it also protects the script from future column additions.


No comments:

Post a Comment