In a procedure that is called fairly frequently I access another server which from time to time decides that my procedure is "deadlock victim", and kills my process. What I would like to do is to check if this occurs, wait a second or two to allow SQL server to deal with the dealock, and try again until I get my statements run. Now this is impossible (to my knowledge) without using a separate process (i.e using a dll or something to make the call). Is there a way you could do this in standard T-SQL?

Btw, 1205 is the code returned by TSQL when a process is judged to be a deadlock victim.

To examplify my problem, consider this pseudo-code which illustrates the above way of thinking:

create procedure ProcName

@ReturnCode int,
@Parameter1 varchar(10),
@Parameter2 varchar(10)

select @Parameter1 = SomeThing, @Parameter2 = SomeOtherThing

set @ReturnCode = 1205
while @ReturnCode = 1205

exec @ReturnCode = master..<DLL-NameGoesHere> @Parameter1, @Parameter2
Waitfor delay '00:00:01'