Hello,
is it possible for a trigger or stored procedure to determine its name?
thanks,
Vadim RappThis returns the name of the currently executing process:
SELECT OBJECT_NAME(@.@.PROCID)
David Portas
SQL Server MVP
--|||Vadim Rapp wrote:
> Hello,
> is it possible for a trigger or stored procedure to determine its
> name?
> thanks,
> Vadim Rapp
You can use something like:
create table abc1234 (col1 int)
go
create proc dbo.abc123
as
select object_name(@.@.PROCID)
go
create trigger abc1234_ins on dbo.abc1234
for insert
as
select object_name(@.@.PROCID)
exec abc123
insert into abc1234 values (5)
drop table abc1234
go
drop proc abc123
go
David Gugick
Imceda Software
www.imceda.com|||It is possible, using @.@.PROCID and OBJECT_NAME() :
CREATE PROCEDURE testprocedure AS
SELECT OBJECT_NAME(@.@.PROCID)
GO
EXEC testprocedure
GO
CREATE TABLE t (i int)
GO
CREATE TRIGGER testtrigger ON t AFTER INSERT
AS
DECLARE @.n SYSNAME
SET @.n = OBJECT_NAME(@.@.PROCID)
RAISERROR (@.n,16,1)
GO
INSERT INTO t(i) VALUES(1)
GO
DROP PROCEDURE testprocedure
GO
DROP TABLE t
Jacco Schalkwijk
SQL Server MVP
"Vadim Rapp" <vrapp@.nospam.polyscience.com> wrote in message
news:eBwN1UQRFHA.1476@.TK2MSFTNGP09.phx.gbl...
> Hello,
> is it possible for a trigger or stored procedure to determine its name?
> thanks,
> Vadim Rapp|||Thanks everyone!
Vadim
No comments:
Post a Comment