Where Do I Want To Go Today? - Upsert
Taking a note from Microsoft's own page, I've decided to share some of my wishes for where I want SQL Server to go. Today.
Meaning this is what I'm looking for now, the things that I'd like to see implemented in future releases. Now I missed the Yukon preview and haven't read too terribly much on it, so I may be asking for something that's coming. If it's not under NDA, let me know.
Otherwise I hope to get some feedback about whether you'd like to see this feature or not. Or maybe you've got something I've forgotten on this feature. Either way let me know. I've got a few and I'm splitting them up to keep comments focused on this one feature. If you've got a wish, send it to me with a description. I'll credit you (if you want) and add my comments before dropping it out there in front of everyone.
I heard this term in a DB2 presentation. And I immediately thought, "we need this in SQL Server". So what is it? It's a combination insert/update statement for a row which basically says: if this row exists, based on the primary key, update the other values with what's included. If not, insert the row.
Simple enough, huh? It is and I can't tell you how many times I've written this code and jumped through some hoops. Especially on imports. I get a list of some sort, need to import it and then update existing information and insert new information.
It is fairly simple code.
But it can be a pain and if there is a constant need for it, something that we perform often, then shouldn't it be built into the language? Wouldn't the brain trust in Redmond to a much more efficient job of implementing this in their C++ (or C# now) code than I can in T-SQL?
I'd think so. This is something that I see often enough in our forums and have the need for myself that I'd like to see it in SQL Server if not in the SQL-04 standard.
Agree? disagree? Let me know.
©dkRanch.net May 2003