Another solution to my original problem (unit testing t-sql - continuing after expected error)
I am surprised this works really - a more reliable check for sql server to make would be "bindtoken after == bindtoken before"
Because this can lead to total chaos:
go
create proc PreserveTrancount as
begin
declare @trancount int
set @trancount = @@trancount
--
if (xact_state() <> 0) rollback tran
--
while (@@trancount < @trancount) begin tran
end
go
select @@trancount
exec PreserveTrancount
select @@trancount
go
begin tran
select @@trancount
exec PreserveTrancount
select @@trancount
rollback tran
go