• Gianluca Sartori (7/15/2010)


    ...but consider that this solution can lead to very extensive row locks if run inside transactions...

    Yes that's one of the things to watch out for, though it's not limited to row locks of course.

    There's nothing wrong with using a CLR function to work around this (the EXTERNAL_ACCESS permission set is required, but that's not something to worry about). The other solution, in SQL Server 2008, is to use a loopback linked server, using sp_serveroption to set remote proc transaction promotion off. This allows autonomous transactions too.

    I also wrote an article about this last year, but decided it would not be of interest to sufficient people to make it worth publishing.

    Paul