My issue is that I want to run a query to check if the data I am using will be a duplicate of something already in the database, for example I have a Product Code and want to stop the same item being listed multiple times, and this Product Code is the Primary Key.
Can I avoid doing this:
SELECT ProductCode FROM tblProducts WHERE ProductCode = '12345'
And then checking for any returned records, or is there a more elegant solution, I don't mind using this method but it seems clunky to be. This is just some extra validation to my code as the insertion of a product should only happen once - but I want error checking on this as duplicates have been entered due to refresh or back button use (web-based system).
Wonder if this is the P = NP type problem or am I overthinking the problem?
My Database is MS SQL Server 2000 if this helps.