Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
YAQ on BIZ and DA tiers
Message
 
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01419401
Message ID:
01421723
Views:
61
>Well, I'm not sure what you mean in the case of MS SQL. I send data (one row of data at a time), to what I call a PUT Stored Proc and depending on the value of the PK parameter that gets passed, the SP knows to do an INSERT (if the PK is < = 0) or an UPDATE for any other PK value. OK, I make an assumption there that an invalid PK won't get passed. So, I'm not sure what you mean by a sequence of INSERT followed by UPDATE.
>
>
>Bonnie, you may be interested to know (and perhaps you already know this) that with SQL 2008, you can pass an ADO.NET DataTable as a parameter to a 2008 stored proc. Basically, there's a new Table type. As I mentioned to Christof, 2008 also has a MERGE capability where you can do INSERT and UPDATE operations in a single line of code.
>
>Also, at one point I thought this was going to come up, but it didn't, still I'll mention it anyway....starting in 2005, in an UPDATE or INSERT statement, you can OUTPUT data from the INSERTED/DELETED tables (that were previously available only in triggers). So one can insert or update, and output columns from INSERTED/DELETED (which might include new identity PKs generated) without needing another SELECT statement or another call back to the database.

I'm trying to figure out why one would need to do an INSERT and UPDATE in one line of code. The same table?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform