F
fredo97
Hi,
I'm new to Access/SQL and have a problem with a query that I just cant seem
to be able to solve.
So, I have an Access database containing client number, security name and
date, that information has to be updated every month, the source for the
update being an excel file that I link to the Access database. But I dont
want to overwrite on the existing data so what i wanted to do was add the
current month's data, when it's not already in there.
What I did was an insert query which inserts the data from the excel file to
the table in the Access database only if the column containing the date of
the data is different from what is already in the database.
Here is what I came up with and it is not workin and i dont understand why:
INSERT INTO DatabaseTable ( Client, Security, Date )
SELECT ExcelTable.Client, ExcelTable.[Security Description], ExcelTable.Date
FROM ExcelTable
WHERE (((Exists (SELECT 1 FROM DatabaseTable WHERE DatabaseTable.Date =
ExcelTable.Date)=false)));
The query doesnt insert any rows and looks as though it considers the dates
from the two tables are identical even though they are not.
Can anyone help please ?
Thanks,
Fred
I'm new to Access/SQL and have a problem with a query that I just cant seem
to be able to solve.
So, I have an Access database containing client number, security name and
date, that information has to be updated every month, the source for the
update being an excel file that I link to the Access database. But I dont
want to overwrite on the existing data so what i wanted to do was add the
current month's data, when it's not already in there.
What I did was an insert query which inserts the data from the excel file to
the table in the Access database only if the column containing the date of
the data is different from what is already in the database.
Here is what I came up with and it is not workin and i dont understand why:
INSERT INTO DatabaseTable ( Client, Security, Date )
SELECT ExcelTable.Client, ExcelTable.[Security Description], ExcelTable.Date
FROM ExcelTable
WHERE (((Exists (SELECT 1 FROM DatabaseTable WHERE DatabaseTable.Date =
ExcelTable.Date)=false)));
The query doesnt insert any rows and looks as though it considers the dates
from the two tables are identical even though they are not.
Can anyone help please ?
Thanks,
Fred