In MySQL it is very easy to make dual primary keys and then we can run the
INSERT INTO table x
SET
val = x,
val2 = y,
val3 = z,
ON DUPLICATE KEY SET val3 = z
Which saves time instead of doing a count and then an insert or update depending on the result.
This seems very complicated in MS SQL with it opting for this MERGE
syntax.
My question is this can I make a stored procedure where I pass - the table name, fields I want to insert and then the values I would like to update.
I would then like the stored procedure to take that go away and just either do the update or the insert whichever is necessary - much like MySQL does.
I'm not very good with stored procedures on the whole and at present I'm resorting to deleting the rows and then inserting them back in as it seems to be the easiest thing to do.
I'm using PHP and ms-sql 2012