Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is the best way, in your opinion?
Message
 
 
To
09/01/2009 07:02:13
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01372218
Message ID:
01372360
Views:
18
>>Hi everybody,
>>
>>Just wondering do you agree with the last statement or not in this thread http://forums.asp.net/t/1368290.aspx ? Does it make sense to do UPDATE first, then INSERT? Or do check first? Or would be no difference here?
>>
>>Thanks in advance.
>
>Nispters' quick solution sample 2 is the worst I have ever seen:) It is a solution w/o thinking. Do not use that one and you could use any way you want:)
>
>I prefer the method posted by the original poster ( update, rowcount = 0 then insert - even in native VFP this was the way I were using). I think it is better than checking for existence first, because:
>
>exits?
> yes - update (total operations 2, exists + update)
> no - insert (total operations 2, exists + insert)
>
>In the other way:
>Update
> ( rowcount is a return value ) = 0?
> no - done (total operations 1 Update)
> yes insert (total operations 2 Update/fail/insert)
>
>PS: However there is another problem that would make this useless and the best way would be to use separate update and insert. Consider you are updating but update fails because of another reason (such as timestamp is your update's part, someone else has changed in between). I don't imply if exists() here but maybe. I know it at client side if I am updating or inserting and be explicit.
>
>Cetin

Thanks, Cetin.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform