Is there any better way to check for a record's existence before insert/updates other than SELECT?
For example, I poll many pieces of hardware, and put the results in a database. I want to see if equipment ABC is listed with IP Address 1.2.3.4. If it is already there, I want to update the desciption fields, otherwise, I need to add it.
Basically, on the client side (in this case the poller) I run:
SELECT * FROM Hardware WHERE Device='ABC' AND IP='1.2.3.4'
If I don't return a record, then I INSERT the appropriate data. If I do return a record, I UPDATE that record.
If I still need to do this, should I convert the whole thing to a stored procedure on the server? I want the process to be as efficient as possible, as I will be updating thousands of records every time I run the poller.
Thanks for all input.
Kevin
PS - I run SQL 2000, and don't have many end users (<100), front end is ASP.
For example, I poll many pieces of hardware, and put the results in a database. I want to see if equipment ABC is listed with IP Address 1.2.3.4. If it is already there, I want to update the desciption fields, otherwise, I need to add it.
Basically, on the client side (in this case the poller) I run:
SELECT * FROM Hardware WHERE Device='ABC' AND IP='1.2.3.4'
If I don't return a record, then I INSERT the appropriate data. If I do return a record, I UPDATE that record.
If I still need to do this, should I convert the whole thing to a stored procedure on the server? I want the process to be as efficient as possible, as I will be updating thousands of records every time I run the poller.
Thanks for all input.
Kevin
PS - I run SQL 2000, and don't have many end users (<100), front end is ASP.