On Thu, 6 Sep 2007 00:30:03 -0400, Rogers wrote:
Quote:
I want to create DDL trigger like if any view create in the database I want
to know the name of the view. |
Hi Rogers,
In a DDL trigger, data about the firing event is available through the
EVENTDATA() function. This returns an xml value, so you'll have to use
XQuery to extract individual values.
For finding the name of the view just created, you can use
CREATE TRIGGER trg_SelectViewRights ON DATABASE
FOR CREATE_VIEW
AS
BEGIN
SELECT EVENTDATA().value('(/EVENT_INSTANCE/ObjectName)[1]',
'nvarchar(128)');
END;
go
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis