Results 1 to 2 of 2

Thread: ? Best way to determine if DB records already exist?

  1. #1
    Guest

    Question

    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:

    Code:
     
    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!

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    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'"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width