Software Blog

Let's Talk Software

SQL Tool Belt: Merge Statement

Database, Database, Database. They are everywhere, and have been for a long time. Personally I find working with a database enjoyable, especially when the requirements get twisted and you need to expand your mind to solve the problem. This blog post is not about one of those mind-bending situations. Just some basics that help with everyday SQL. This one is actually dated now, but still not used as much as it probably should be.

 MERGE

Starting back in SQL 2008 you could use the MERGE command to essentially combine your INSERT, UPDATE, DELETE logic into a single statement. This is nice if you still write your SQL code (which I do) and haven't moved to an ORM (note: I'm not a fan), but that is for another post another day.   Best way to learn is to see an example:

read more
RSS
<1>