PDA

Click to See Complete Forum and Search --> : ? Best way to determine if DB records already exist?


Aug 11th, 2000, 11:09 AM
In my proggie, data is imported from a delimited text file to a grid. The primary identifier of each entry is the date; for example, 08/10/2000 as rs.fields(1).

When the imported text is saved to the database, I need to determine if the dates already exist so that the newer data does not create duplicates. Is there a better way than:


sSQL = "SELECT ACDDate FROM " & sRS & " WHERE [ACDDate] BETWEEN '08/01/2000' AND '08/30/2000'"


And then testing whether the RS is empty or contains recordsets?

Thanks!

JHausmann
Aug 11th, 2000, 11:33 AM
1) Access will want your dates delimited by "#"
2) when checking for the existience of keys, you want to check at the level of uniqueness; ie; you'd want to look for a single date instead of a range.

for Access you'd want to use:
sSQL = "SELECT ACDDate FROM " & sRS & " WHERE [ACDDate] = #08/06/2000#"

for SQL server you'd want to use:

sSQL = "SELECT ACDDate FROM " & sRS & " WHERE ACDDate = '08/06/2000'"