Did you ever wonder if it was possible to do an update or insert in one query? Normally you would write a select query and execute some C# code to see if a certain record already exists and if so do an update and if not do an insert. Besides three SQL query executions this also involves a lot of C# code and doesn't feel like a very efficient approach.
One day I was looking for a better way to solve this very common situation and created this query:
SET columnOne = 'valueOne', columnTwo = 'valueTwo',
WHERE Identifier = 123456
IF @@ROWCOUNT = 0
INSERT INTO Table
(columnOne, columnTwo) VALUES ('valueOne', 'valueTwo')
So the query tries to update the record and if the @@ROWCOUNT returns 0, nothing was updated and it will do an insert.