I have a MS SQL Server Database with about 75 tables on it, and I am trying to insert records into tables if a record with the same primary key doesn't exist, or update if they do. I could hard code the primary keys for every table into my vb.net code, but I'd rather not as more tables are to be added at a later date and my code needs to handle this without being changed. Is there a way to pull out the primary key column name(s) from a table using a query so I can loop through each table executing the same code?
Thanks, Tom
P.S. I am a bit of a newbie when it comes to SQL so if you have the time please be simple and clear with any responses.