I need to insert "distinct" records in one table with a sql statement.
Following is the statement:
xSQL = "INSERT INTO HeaderFile ([Date], [Grp], [Reg], [ServLoc], [AcctNo], [InvNo], [Unit]) IN '\\C:\MyDB.mdb' SELECT DLFile.Date, DLFile.Grp, DLFile.Region, DLFile.ServLoc, DLFile.AcctNo, DLFile.InvNo, DLFile.UNIT FROM DLFile WHERE DLFile.Grp = """ & ProcGrp & """"
The DLFile contains the same information (except unit) on each line. (I didn't set up the database but I have to live with it.)
So what I would like to do is only insert the unique records baseed on Date, Grp, Reg, ServLoc, AcctNo, InvNo, and Unit.
I've seen some examples of selecting distinct records, writing them to a temp table and then writing them to the HeaderFile table from the temp table.
I'm hoping that I can do it right from the INSERT statement.
Thanks for the help.
Following is the statement:
xSQL = "INSERT INTO HeaderFile ([Date], [Grp], [Reg], [ServLoc], [AcctNo], [InvNo], [Unit]) IN '\\C:\MyDB.mdb' SELECT DLFile.Date, DLFile.Grp, DLFile.Region, DLFile.ServLoc, DLFile.AcctNo, DLFile.InvNo, DLFile.UNIT FROM DLFile WHERE DLFile.Grp = """ & ProcGrp & """"
The DLFile contains the same information (except unit) on each line. (I didn't set up the database but I have to live with it.)
So what I would like to do is only insert the unique records baseed on Date, Grp, Reg, ServLoc, AcctNo, InvNo, and Unit.
I've seen some examples of selecting distinct records, writing them to a temp table and then writing them to the HeaderFile table from the temp table.
I'm hoping that I can do it right from the INSERT statement.
Thanks for the help.