Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to get the table name in the trigger definition without hard coding.

$
0
0

CREATE  TRIGGER db.mytablename

AFTER UPDATE,INSERT

AS

    INSERT INTO table1(col1)

    SELECT InsRec.col1   

    FROM

    INSERTED Ins

   --Below i am calling one sp for which i have to pass the table name

   EXEC myspname 'tablename'

 

  In the above trigger,presently i am hard coding the tablename

  but is it possible to get the table name dynamically on which the trigger is defined in order to avoid hard coding the table name


Viewing all articles
Browse latest Browse all 23857

Trending Articles