Using INSERT INTO and setting one field value - Access VBA
I'm using INSERT INTO to copy rows of data from one table to another:
INSERT INTO tblNewCustomers (CustomerID, [Last Name], [First Name])
SELECT CustomerID, [Last Name], [First Name]
FROM tblOldCustomers
How can I set one of the field values in tblNewCus开发者_Python百科tomers for all of the new records that I am importing in withn this statement e.g
tblNewCustomers.existCustomer = TRUE
Thanks in advance for any help
Noel
INSERT INTO tblNewCustomers (CustomerID, [Last Name],
[First Name], [existCustomer])
SELECT CustomerID, [Last Name], [First Name], True
FROM tblOldCustomers
You can also ignore the field in the SQL sentence and make it have a default in true. BUT I think Smandoli solution is more accurate
精彩评论