Yes, my apologies, I was referring to a trigger. And you are correct
in that it's possible to always statically determine what table is in
my context, based on the trigger. But I wish to write a series of
triggers that all perform nearly identical tasks, except they act
w.r.t. the table which called them. Like so:
CREATE TRIGGER trg_Table1 ON Table1 FOR INSERT
AS
INSERT INTO foo (invocation) VALUES (this)
GO
CREATE TRIGGER trg_Table2 ON Table2 FOR INSERT
AS
INSERT INTO foo (invocation) VALUES (this)
GO
"David Portas" <RE****************************@acm.org> wrote in message news:<yO********************@giganews.com>...
That doesn't make sense. A stored procedure can't be called by a table -
tables are just data structures. In SQL there is no concept of a "current"
table - all tables are available at all times.
Maybe you are referring to Triggers, but since a trigger can only apply to a
single table there shouldn't be any doubt about which table caused the
trigger to fire.
A user-defined function can be called from within a query, view or computed
column but to supply a UDF with information such as a table name you would
need to pass that information as a function parameter.