@Erland Sommarskog , thank you. I wrote some test code, and your answer is consistent with what I found (assuming you meant to say "... brings down @@trancount to 0" in your second paragraph.
In the code sample below, I put the output from each statement in a comment after the statement. It clearly shows that the hstEnd value (2021-08-16 22:24:26.153) is set to the time just before the outer transaction is opened (2021-08-16 22:24:26.1529567).
Thank you.
use tempdb
GO
DECLARE @Tbl nvarchar(100) = N'dbo.Status';
IF (2 = (SELECT temporal_type FROM SYS.TABLES WHERE object_id = OBJECT_ID(@Tbl, 'U ')))
EXEC(N'ALTER TABLE ' + @Tbl + N' SET (SYSTEM_VERSIONING = OFF);');
EXEC(N'DROP TABLE IF EXISTS ' + @Tbl + N'_hst;');
EXEC(N'DROP TABLE IF EXISTS ' + @Tbl + N';');
GO
CREATE TABLE dbo.Status (
hstStart datetime2(3) GENERATED ALWAYS AS ROW START
, hstEnd datetime2(3) GENERATED ALWAYS AS ROW END
, PERIOD FOR SYSTEM_TIME(hstStart, hstEnd)
, RPTY_ID int NOT NULL
, CACHE_IQ int NOT NULL
, RUN_REPO_ID int NULL
, RowzR int NULL
, RowzD int NULL
, CONSTRAINT PK_RPST PRIMARY KEY NONCLUSTERED (RPTY_ID, CACHE_IQ)
)
WITH (
SYSTEM_VERSIONING = ON (
HISTORY_TABLE = dbo.Status_hst
)
);
GO
insert dbo.Status (RPTY_ID, CACHE_IQ, RUN_REPO_ID, RowzR, RowzD)
values (2, 1234, 444, 1, 2)
;
/*
(1 row affected)
*/
GO
select SYSUTCDATETIME()
;
/*
---------------------------
2021-08-16 22:24:26.1529567
(1 row affected)
*/
begin tran
;
waitfor delay '00:00:05'
;
select SYSUTCDATETIME()
;
/*
---------------------------
2021-08-16 22:24:31.1686990
(1 row affected)
*/
begin tran
;
update st set
RowzR = 11
, RowzD = 22
from dbo.Status st
where st.RPTY_ID = 2
and st.CACHE_IQ = 1234
;
/*
(1 row affected)
*/
waitfor delay '00:00:05'
;
select SYSUTCDATETIME()
;
/*
---------------------------
2021-08-16 22:24:36.1844797
(1 row affected)
*/
commit tran
;
waitfor delay '00:00:05'
;
select SYSUTCDATETIME()
;
/*
---------------------------
2021-08-16 22:24:41.2001498
(1 row affected)
*/
commit tran
;
select * from dbo.Status for system_time all
;
/*
hstStart hstEnd RPTY_ID CACHE_IQ RUN_REPO_ID RowzR RowzD
--------------------------- --------------------------- ----------- ----------- ----------- ----------- -----------
2021-08-16 22:24:26.153 9999-12-31 23:59:59.999 2 1234 444 11 22
2021-08-16 22:24:26.106 2021-08-16 22:24:26.153 2 1234 444 1 2
(2 rows affected)
*/