说,我有一笔庞大的交易,在不同的时间间隔定义了多个保存点。有没有我可以使用的命令或工具,可以为我提供我在脚本中定义的保存点名称的列表。
begin transaction
save transaction P1;
save transaction P2;
save transaction P3;
declare @startlsn nvarchar(23) =
(
select min(d.database_transaction_begin_lsn)
from sys.dm_tran_database_transactions as d
join sys.dm_tran_current_transaction as c on d.transaction_id = c.transaction_id
where d.database_transaction_begin_lsn is not null
);
declare @tranId nvarchar(14) = (
select top (1) [Transaction ID]
from fn_dblog(@startlsn, @startlsn)
where @startlsn is not null
);
--save points
select [Savepoint Name], *
from fn_dblog(@startlsn, null)
where [Transaction ID] = @tranId;
rollback transaction;