Sharing transaction between two connections?

  • This is a bit complicated so I will try to simplify it as much as possible.

    On SQL Server 2008 I have created a CLR UDF (C#) that opens a connection via a Connection String and writes to a table.

    However, I want the write generated by the UDF to be rolled back if the Transaction invoking the UDF gets Rolled Back.

    I can't use "context connection=true;" as the UDF connection string because it needs a different connection string than the transaction that invoked it.

    This will work using sp_getbindtoken/sp_bindsession. However, these apparently have been deprecated (although they are still in SQL Server 2012).

    I also read up on MARS, but it seems like it would not work in this situation: As far as I can tell, MARS is for multiple batches on a single connection. I have two connections, each of which may have a different connection string, which need to share the same "transaction space".

    Any suggestions would be greatly appreciated.

Viewing 0 posts

You must be logged in to reply to this topic. Login to reply