Mixing Function Values and Table Values With INSERT INTO Clause

gnarpeggio

Registered User.
Local time
Today, 01:37
Joined
Jun 22, 2010
Messages
74
Hello again folks,

I've been driving myself up the wall trying to get this query to add both the values I'm after, but to no avail. Here's my dilemma:

My goal is to add two values into a table; one from a separate table and another generated from a function. This is my SQL so far:

INSERT INTO tbl_Refunds (Item_ID, Fiscal_Month) VALUES (Item_ID, GetFiscalMonth(Date())) SELECT (Item_ID) FROM tbl_Payments ;

Every time I run the query, the missing semi-colon run-time error pops up (3137)! My first guess was that the SELECT clause doesn't have the same amount of fields since my GetFiscalMonth function exists only in module form and not on that table. I'm not too savvy on SQL, so any help is appreciated!

Thanks in advance
 
You can't have both the VALUES clause and the SELECT clause. I'm not clear enough on what you're trying to do, but perhaps:

INSERT INTO tbl_Refunds (Item_ID, Fiscal_Month)
SELECT Item_ID, GetFiscalMonth(Date()) FROM tbl_Payments
 

Users who are viewing this thread

Back
Top Bottom