February 27, 2008 at 9:50 am
Hi,
Is it possible to do some action (or to be informed somehow) when new reference to specific table is added? For example I have database with 500 tables and I have 5 special tables where I need to know when new reference from another table or new reference from new created table appears. Something like trigger on system table. Or DDL trigger on unknown table 🙂
February 29, 2008 at 1:01 am
Nobody can help? 🙁
February 29, 2008 at 3:06 am
Michal Mokros (2/27/2008)
Hi,Is it possible to do some action (or to be informed somehow) when new reference to specific table is added? For example I have database with 500 tables and I have 5 special tables where I need to know when new reference from another table or new reference from new created table appears. Something like trigger on system table. Or DDL trigger on unknown table 🙂
You could create a DDL trigger for the database for the CREATE_TABLE and the ALTER_TABLE events.
E.g.:
CREATE TRIGGER ddl1 ON DATABASE
FOR ALTER_TABLE, CREATE_TABLE
AS
BEGIN
SELECT EVENTDATA()
END
The problem is the granularity of the information you will get back. You will need to go through the CommandText element in the EVENTDATA and look for the REFERENCES word, and work out the the referenced table. You may want to do this in CLR, in TSQL it may become a pain.
Regards,
Andras
February 29, 2008 at 8:12 am
It will be quite complicated to parse EVENTDATA, but it is possible. Thank you, Andras!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply