Here's a solution that makes use of a loopback linked server connection. That allows to update a table outside of the current transaction context:
use TEST; -- assume the database is named TEST
create table SeqNo (
SeqName nvarchar(10) not null primary key,
LastValue int default 0
);
insert into SeqNo (SeqName) values ('A'),('B');
create table Protocol (
id int not null primary key identity(1, 1),
SeqName nvarchar(10) not null,
SeqNo int not null,
SomeText nvarchar(100)
);
GO
EXEC master.dbo.sp_addlinkedserver @server = N'MyLoopback',
@srvproduct = N'',
@datasrc = @@SERVERNAME, -- use own server
@provider = N'SQLOLEDB',
@catalog=N'TEST';
GO
EXEC master.dbo.sp_serveroption @server=N'MyLoopback', @optname=N'remote proc transaction promotion', @optvalue=N'false';
EXEC master.dbo.sp_serveroption @server=N'MyLoopback', @optname=N'rpc', @optvalue=N'true';
EXEC master.dbo.sp_serveroption @server=N'MyLoopback', @optname=N'rpc out', @optvalue=N'true';
GO
/* We did the preparation work, now do a test... */
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
BEGIN TRANSACTION;
declare @SeqName nvarchar(10);
set @SeqName = N'A';
declare @NewSeqNo int;
exec (N'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
BEGIN TRANSACTION;
declare @tmp table (NewValue int);
update SeqNo set LastValue = LastValue + 1 output inserted.LastValue into @tmp where SeqName = ?;
select top 1 ?=NewValue from @tmp;
COMMIT TRANSACTION;', @SeqName, @NewSeqNo output) at MyLoopback;
insert into Protocol (SeqName, SeqNo, SomeText) values (@SeqName, @NewSeqNo, N'Whatever you want');
ROLLBACK TRANSACTION; -- alternatively "COMMIT TRANSACTION" to have the row in Protocol persistent
select * from Protocol;
select * from SeqNo; -- became updated, even if rolled back (outer) transaction above