Difference with raisError

I wanted to test the updlock hint , inside a transaction, for how long it’s keep.
(From what I remember, it’s kept till the end of the transaction.)
So, I decided to test it.

use StackOverflow2013
go
set nocount on
go

begin tran
select *
from dbo.Users with(updlock)
where id = 9567299;

select *
from dbo.Posts with(updlock)
where id = 17;

waitFor delay '00:00:10';   

rollback tran


At some point, let’s add a RAISERROR(‘interior1 ‘,0,1) with NOWAIT;

use StackOverflow2013
go
set nocount on
go

begin tran
select *
from dbo.Users with(updlock)
where id = 9567299;

select *
from dbo.Posts with(updlock)
where id = 17;

RAISERROR('interior1 ',0,1) with NOWAIT;
waitFor delay '00:00:10';   

rollback tran

Interesting point, is that with out RaisError, the results are display after the end of delay
But with raiserror with nowait, the result are display right away.

NOWAITSends messages immediately to the client.



S