Below code saying error
incorreect syntax near "Main"
INSERT INTO tbl (
'Week',
Main,
a,
b,
c,
d,
e
)
Select 'Week',
Main,
a,
b,
c,
d,
e
FROM tbl_link
Below code saying error
incorreect syntax near "Main"
INSERT INTO tbl (
'Week',
Main,
a,
b,
c,
d,
e
)
Select 'Week',
Main,
a,
b,
c,
d,
e
FROM tbl_link
INSERT INTO tbl (
'Week',
You should insert actual field name here.
If you field is called Week
, just get rid of the quotes:
INSERT INTO tbl (
Week,
Main,
a,
b,
c,
d,
e
)
Select 'Week',
Main,
a,
b,
c,
d,
e
FROM tbl_link
, otherwise substitute the field name.
INSERT INTO tbl (
[Week],
Main,
a,
b,
c,
d,
e
)
Select [Week],
Main,
a,
b,
c,
d,
e
FROM tbl_link
To clarify the other answers:
SQL INSERT
syntax with SELECT
statements is as followings:
INSERT INTO Table(Column1Name, Column2Name, ...)
SELECT
Column1Data, Column2Data, ...
FROM Table
The parenthesized list after the table name you intend to update is the ordered list of columns on that table that you intend to populate. It does not represent data that will make its way to the table.
there are two possible issues here:
Based on your INSERT attempt, your tables tbl and *tbl_link* must should both have columns named: [week],Main,a,b,c,d, and e. If not you must rethink what you are trying to do. The first list of columns have to all exist within table tbl, and the second list of columns must all be within table *tbl_link*. If there are column in tbl that are not in *tbl_link*, you can just eliminate them from the INSERT:
INSERT INTO tbl ( [Week], a, b, c ) Select [Week], a, b, c FROM tbl_link