Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

How to find source, that inserted data into a table?

$
0
0
Hi all!

I have a lot of stored procedures, which can insert data into the table.
How can I find which stored procedure inserted the certain row?

I wrote a trigger:
Quote:

CREATE TRIGGER dbo.TraceTheProcedure
ON dbo.SomeTableToTrace
FOR INSERT, UPDATE AS
Insert into DedugTable
Select getdate() as EventTime,
object_name(@@procid) as Source,
object_id
From inserted
But all I got is:
Quote:

date [NULL] 239
date [NULL] 240
etc..
So, why does object_name(@@procid) always return null instead of object name? And how to find the name of the procedure?
If I store just @@procid - I get lont integer != 0

regards

Viewing all articles
Browse latest Browse all 13329

Trending Articles