Link to home
Start Free TrialLog in
Avatar of Varshini S
Varshini S

asked on

What is rowversion in SQL Server ? How it is different from MERGE ?

What is rowversion in SQL Server ? How it is different from MERGE ?

We can use MERGE command to  update/insert/delete records in  source and target table.

Then why we need rowversion ?
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Row Version is a data type that exposes automatically generated, unique binary numbers within a database. rowversion is generally used as a mechanism for version-stamping table rows. The storage size is 8 bytes. The rowversion data type is just an incrementing number and does not preserve a date or a time. To record a date or time, use a datetime2 data type. For details refer below -

https://msdn.microsoft.com/en-us/library/ms182776.aspx

Row Version is not related to Merge Statement. Merge is a statement can be used to insert, update and delete rows. Example below-

https://technet.microsoft.com/en-us/library/bb522522(v=sql.105).aspx

Hope it helps !!
Avatar of Austin Texas
Rowversion is a datatype that is used to track changes to records.
Avatar of Varshini S
Varshini S

ASKER

My question is , if i have a two tables source and target and using merge command will take cAre of update or insert the records in target table. Than why i need to use rowversion?
SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial