Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 DDL trigger help

Author  Topic 

wonky donkey
Starting Member

15 Posts

Posted - 2007-08-28 : 04:33:54
Hi guys, wondering if someone could shed some light on this as i'm out of ideas! The code below is for a DDL trigger which fires on a particular database. It works fine and it currently updates the audit2 table. However, i'm struggling to find the correct functions (if they exist) to put in the select statement. The main one i'm searching for is a fucntion that recognises the created tables name. I've trawled through the TSQL function list abd there doesnt appear to be one. Can anyone suggest a good place to find these sorts of fuctions or know of ones i can use to solve my problem??

thanks


CODE


USE [Business]
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO

ALTER TRIGGER [Business_Audit]
ON DATABASE
FOR CREATE_TABLE

AS

DECLARE @rowcount INT


INSERT dbo.Audit2
(AuditDate, SysUser, Application, [Rowcount], [TableName])
SELECT GetDate(), suser_sname(), APP_NAME(), @rowcount, null,

GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
ENABLE TRIGGER [Business_Audit] ON DATABASE

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-08-28 : 05:17:53
look at the EVENTDATA() function.
it holds the xml about the DDL event.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -