Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
petre
Starting Member
11 Posts |
Posted - 2010-06-19 : 06:56:59
|
| hi friend, i was trying to write an inser_update sp that handles cocurrencies. but i wrote it on several ways in either there is bugs (logic errors) so the control doesn't flow the way i wanted. I have an image of flow of control, if i pubslish that would you be able to write this stored procedure that i was trying to write for days and day. this is very simple for nakid eye but gets complicated with the control structure, the requriement is to write a sp that does insert and update operations both. the table sp works on has thrww columns, idx int auto, code char(6)unique not null, rversion timestamp not nullSP should check the following: when insert1. is fresh or existing2. does the entering record has a duplicate value for code3. if all above passed enter the recordwhen update:1. check the record exists before update2. check weather it handles concurrenciesPS i use SQL express 2005cheersPS> im not a db developer |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-06-19 : 07:59:46
|
| http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=56148 - UpSert with "hint" to force INSERT or UPDATE when EXISTS is knownhttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=72835 - Perform either INSERT or UPDATE and if "fail" revert to the otherSQL2005 onwards you can use the MERGE statement for "UpSerts" |
 |
|
|
|
|
|