April 2, 2026 at 7:23 am
can i use Rowversioncol ( in my database it's synonyme timestamp is used) to run the following query to find all inseted after this @LastKnownRowVersion;
SELECT * FROM YourTable
WHERE RowVersionCol > @LastKnownRowVersion;
data type i should use for @LastKnownRowVersion; why i am asking is because i read this from
"A nonnullable rowversion column is semantically equivalent to a binary(8) column. A nullable rowversion column is semantically equivalent to a varbinary(8) column."
https://learn.microsoft.com/en-us/sql/t-sql/data-types/rowversion-transact-sql?view=sql-server-ver17
q2) what should i do if i have non null roversioncol and if i have null roversion col.
April 2, 2026 at 12:31 pm
If you're using rowversion, use the rowversion data type. Can you use others? Sure. Why? What functionality will you get that you don't already have? What functionality will you lose? It's rowversion. You want to use it as rowversion. Leave it at rowversion.
Generally speaking, the simplest answers to any problems in SQL Server are the best.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 2, 2026 at 1:52 pm
use varbinary
@Grant - purpose is normally to use it as "what has changed since last time I did ETL..." so the last rowversion used is stored elsewhere - and can't be rowversion on that case.
April 2, 2026 at 2:56 pm
So you're storing it twice, once as the automated column value and another time as something updated, trigger or what not? I'd go with the varbinary then.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 3, 2026 at 2:25 pm
Figured this board out along with Stack, Leftist not neutral. It's on.
April 3, 2026 at 2:54 pm
Figured this board out along with Stack, Leftist not neutral. It's on.
Sorry, but what?
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 4, 2026 at 7:48 am
can i get any example to understand? when to use varbinary.
April 4, 2026 at 8:04 am
declare @LastKnownRowVersion varbinary(8) = 0x00000000000007D3
SELECT * FROM YourTable
WHERE RowVersionCol > @LastKnownRowVersion;
but both varbinary and binary are the same - only difference is that (as per manual)
A nonnullable rowversion column is semantically equivalent to a binary(8) column. A nullable rowversion column is semantically equivalent to a varbinary(8) column.
April 6, 2026 at 3:05 am
i just wanted to understand your scenario, in your case i can use rowversion and it works.
why i should i use varbinary(8) ,when i have rowversion datatype.
declare @LastKnownRowVersion varbinary(8) = 0x00000000000007D3
SELECT * FROM YourTable
WHERE RowVersionCol > @LastKnownRowVersion;
April 6, 2026 at 12:30 pm
I'm confused. You said you had two columns, one rowversion and one you're going to update in some way, but you want to store it as it was rowversion? In that case, where you're trying to do two columns, then one of them would be varbinary and you're good to go. If you just have one column, then yeah, use rowversion, not anything else.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 10 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply