Append Query

J

Janis

I have and excel spreadsheet I import into a table every week. I wrote this
append query to append this table to a datasheet in access. It works except
I want to only add the new rows where there is a new router. The impRouter
is the key field. It should be in SQL NOT EQUALS TO???

query that appends all the records
INSERT INTO _HSIImport ( impArea, impHeadend, impRouter, impDate )
SELECT [Port History9_1_2007].Area, [Port History9_1_2007].Headend, [Port
History9_1_2007].[Element Name], ([#date#]) AS Expr1
FROM [Port History9_1_2007];


modified query to add only the new router records:
INSERT INTO _HSIImport ( impArea, impHeadend, impRouter, impDate )
SELECT [Port History9_1_2007].Area, [Port History9_1_2007].Headend, [Port
History9_1_2007].[Element Name] NOT EQUALTO [_HSIImport].impRouter,
([#date#]) AS Expr1
FROM [Port History9_1_2007];


I think there is a syntax error.

tia,
 
M

Michel Walsh

can be:

INSERT INTO _HSIImport ( impArea, impHeadend, impRouter, impDate )
SELECT Area, Headend, [Element Name], [#date#]
FROM [Port History9_1_2007]
WHERE [Element Name] NOT IN( SELECT impRouter FROM [_HSIImport] )



Alternatively, you can use an outer join.

Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top