question

Moumit avatar image
Moumit asked

What is the benefit of using rowversion(timestamp) over LastModifyOn(DateTime) column in a table??

**Problem:** I am working on asp.net application and my Intention is to confirm that a table row is updating only when it is not updated in between a user's request and submit. **Scenario:** User X and Y open same invoice(invoiceid=12) in different browser User X changed invoice date to 1-july-2014 in UI. User Y changed invoice date to 5-july-2014 in UI User X press submit button.-- Invoice date changed to 1-july-2014 User Y press submit button.-- Invoice date changed to 5-july-2014. X and Y both did not know whether invoice data is altered between request and submit. **Solution-1:** We added a column LastModifyOn(DateTime) in invoice table When retrieve the invoice data for edit also getting LastModifyOn column data Keeping the encrypted LastModifiedOn data in hidden field in UI When user submitting the invoice data changes, we also sending LastModifiedOn to compare. Showing appropriate message. **Solution-2:** We added a column version(rowversion) in invoice table When retrieve the invoice data for edit also getting version column data Keeping the encrypted version data in hidden field in UI When user submitting the invoice data changes, we also sending version to compare. Showing appropriate message. X and Y knows whether invoice data are altered in between or not. **Question:** Now my question is what benefit we will get by using **version(rowversion)** column over **LastModifyOn(DateTime)**... **Point:** We are audit trailing in invoice table so last updated on data is already available. Please mention strong points in reason not like we do not need to update rowversion column explicitly or definition of timestamp ..
sql-server-2008-r2datetimeasp.netarchitecturetimestamp
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Grant Fritchey avatar image
Grant Fritchey answered
Well, one of the advantages of rowversion is that you don't have to explicitly define it in your statatements. The only other real difference is that you have a human readable datetime with the datetime value. Is that necessary for your situation or not? Other than those two distinctions, there really aren't many differences.
3 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

I expected something more interesting from you people :(
0 Likes 0 ·
Sorry. Rowversion isn't exactly a deep and abiding topic filled with reams of information. It does what it does. You need it or you don't.
0 Likes 0 ·
It's may be .. But still i don't think this is an acceptable answer.. :(
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.