Re: min_active_rowversion ( was Re: Triggers and Flag bit)

Erland Sommarskog wrote:
> Sharif Islam (mislam [at] spam.uiuc.edu) writes:
>> Thanks for the help. Here's how I am using it. I created a column 'Flag'
>> with timestamp datatype.
>>
>> ------
>>
>> declare [at] before timestamp
>> declare [at] after timestamp
>> set [at] before= min_active_rowversion() -1
>> update MyTable set MyCol ='Test' where MyCol like 'Test123%'
>> set [at] after = min_active_rowversion() -1
>>
>> select ID,MyCol from MyCol where Flag -1 < [at] after
>> and Flag -1 >= [at] before
>> -----
>> This gave me the list of record ID that was just changed. Is this the
>> way to use min_active_rowversion()?
>
> Hm, not really.
>
> Your Perl script would run a batch like:
>
> DECLARE [at] new_highwater_mark rowversion
> SELECT [at] new_highwater_mark = min_active_rowversion()
>
> SELECT ID, MyCol, [at] new_highwater_mark
> FROM tbl
> WHERE tstamp >= [at] last_highwater_mark AND
> tstamp < [at] new_highwater_mark
>
> That is, the Perl script needs to remember [at] new_highwater_mark, and pass
> it as [at] last_highwater_mark next time.
>
> It's important to capture min_active_rowversion() into a variable, because
> it could change while the query is running, which could lead to lost
> updates.
>
>
Got it! Thanks a lot.
Sharif Islam [ Mo, 31 März 2008 03:19 ] [ ID #1932824 ]
Datenbanken » comp.databases.ms-sqlserver » Re: min_active_rowversion ( was Re: Triggers and Flag bit)

Vorheriges Thema: Re: Doing Summation on multiple criterias on the same column in a single query
Nächstes Thema: Namespace problem in Bulkload