Transact-SQL: ottenere la tabella corrente all’interno di un trigger/store procedure

SELECT tabella = object_name(parent_obj)
  FROM sysobjects
 WHERE id = @@procid

Note:

  • sys.sysobjects: Contiene una riga per ogni oggetto creato all’interno di un database, ad esempio un vincolo, un valore predefinito, un log, una regola o una stored procedure.
  • @@procid: restituisce l’ID (object identifier) del modulo corrente Transact-SQL come store procedure, funzioni definite dall’utente o trigger.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>