|
-
The problem, as svk said, is that you must match the columns in the INSERT clause with columns in the SELECT or VALUES clause.
Therefore, if you wish to exclude a column from the INSERT, you *need* to list the other columns in the INSERT clause.
So, if you have TABLE1 with COL1 and COL2,
INSERT INTO
--TABLE1
VALUES
--(1, 2)
...works fine. However, if you wish to let Col2 use a default instead, the following *will not* work:
INSERT INTO
--TABLE1
VALUES
--(1)
The correct syntax would be:
INSERT INTO
--TABLE1
--(COL1)
VALUES
--(1)
Actually, you should *always* specify a column list for every INSERT. Correspondingly, you should *always* specify the entire column list for every SELECT (ie, SELECT * is bad!). Trust me, you will save yourself headaches down the line :)
HTH,
- Chris
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|