Guys, I think I've asked this question in the past but got pulled away and never got back to it, but now I have some more time. My question has to do with general SQL usage.
1) Let's say I have a database with a list of computers and some fields such as computerName(PK), customerName, phone, and so on.
2) Let's say I have a folder where a file or files may exist named computerName.txt. In that file(s) will be the fields I have above. The file may be a new name not yet in the database or it may be an existing name with some of the fields having updated values. After I finish with the file I delete it. I then check back again hourly to see if there are any new files in the folder.
3) Now I want to scan that folder, read each file, and put it into the database.
My problem is that all the tutorials I have seen for INSERT assume there are no entries with the PK already in the database. How do I check for the record and if it's in the database check the fields to see if any of the values have changed and UPDATE them? If the record does not exist then INSERT the new record into the database.
I imagine this is done with subqueries right? Can you guys give me some psuedo to show me how it's done? Thanks.










Bookmarks