SQL Server Central is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

Where Do I Want To Go Today? - Upsert

By Steve Jones, 2003/07/28

Total article views: 7605 | Views in the last 30 days: 13

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.

Upsert

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.

Steve Jones
©dkRanch.net May 2003


Return to Steve Jones Home

By Steve Jones, 2003/07/28

Total article views: 7605 | Views in the last 30 days: 13
Your response
 
 
 
Already registered?  

Free registration required

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Register

E-mail address:
Password:
Password (confirm):

  

Subscriptions

We ask you to register on the site and subscribe to our newsletters. Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.

Steve Jones
Editor, SQLServerCentral.com