Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check values on the server
Message
 
 
To
24/05/2010 12:57:54
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01465718
Message ID:
01465730
Views:
39
>Thank you for your reply.
>
>If I understand correctly to use RowVersion I can do something like
>UPDATE Table SET... WHERE RowVersion=myRowVersion.
>
>And if the RowVersion was changed the update will not happen.
>But by that time all the changes that user made during his session will be gone and I am not sure how would I know that the change was not saved and let user know why.
>You mention a comparison, how do I go about it? I am sorry if my questions are too dilettante.
>
>Thank you again
>
>

You will do something like (from the top of my head)
if exists (select 1 from myTable where Pk = @myPK and RowVersion <> @MyRowVersion)
  begin
  -- someone already modified the data
  select @Col1Changed = Col1, @Col2Changed = Col2 from myTable where Pk = @myPk
  raiserror('While you were working, another user has changed the data and the new values are: Col1 = %s, Col2 = %s',16,1,@Col1Changed, @Col2Changed)
   return - 1
  end
else
  --proceed with normal update
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform