How to use the merge command
- by Vaccano
Say I have a table called Employee (has ID, NAME, ADDRESS, and PHONE columns). (Not my real problem, but simplified to make the question easier.)
If I call a sproc called UpdateEmployee and I pass in a @Name, @Address, @Phone and @ID.
Can merge be used to easily check to see if the ID exists? If it does to update the name, address and phone? and if it does not to insert them?
I see examples on the net, but they are huge and hairy. I would like a nice simple example if possible.
(We recently upgraded to SQL 2008, so I am new to the merge command.)