• Jeff Moden (10/21/2012)


    Ahhhh... getting back to the original subject of how to get the table name... I found an interesting bit of code that Remi suggested at the following URL. I've not tried it but I believe it'll work and it's certainly more reliable than the primary key name hack. Here's the URL.

    http://www.sqlservercentral.com/Forums/FindPost298963.aspx

    Yeah, I had tried that. But this doesn't work when inside a CLR: @@procID doesn't return a valid object_id when called from a CLR trigger. I have not been able yet to find what the number does represent, but it is the same number no matter from which table the CLR audit trigger got fired (reference).

    But: your suggestion has given me the idea that maybe I can create a T-SQL trigger that calls a CLR procedure; the T-SQL code CAN get a @@procID that is unique per table. All it needs to do is pass this to the CLR... I'll let you know what happens monday morning!



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?