VIVEKANANDHAN_PERIASAMY
asked on
Need a sample SQL Trigger for DDL statement that are execute on database
Need a sample SQL Trigger for DDL statement that are execute on database
ASKER
sorry i missed to mention "truncate" statement. I want to capture only truncate statement exceute on my database.
Isn't a truncate statement a DML Statement
http://msdn.microsoft.com/en-us/library/ms189599(v=sql.105).aspx
The "truncation" trigger may not be possible...
see
http://msdn.microsoft.com/en-us/library/ms189799.aspx
specifically....
Although a TRUNCATE TABLE statement is in effect a DELETE statement, it does not activate a trigger because the operation does not log individual row deletions. However, only those users with permissions to execute a TRUNCATE TABLE statement need be concerned about inadvertently circumventing a DELETE trigger this way.
http://msdn.microsoft.com/en-us/library/ms189599(v=sql.105).aspx
The "truncation" trigger may not be possible...
see
http://msdn.microsoft.com/en-us/library/ms189799.aspx
specifically....
Although a TRUNCATE TABLE statement is in effect a DELETE statement, it does not activate a trigger because the operation does not log individual row deletions. However, only those users with permissions to execute a TRUNCATE TABLE statement need be concerned about inadvertently circumventing a DELETE trigger this way.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Temp
I see you are right DDL for Truncate.
I think that is incorrect...but hey... bigger brains than mine have decreed it so.
The way I see it... Truncate is manipulating the data, not changing the structure of the table. Hence DML not DDL.
T
I see you are right DDL for Truncate.
I think that is incorrect...but hey... bigger brains than mine have decreed it so.
The way I see it... Truncate is manipulating the data, not changing the structure of the table. Hence DML not DDL.
T
Check out the msdn for truncate in the following link. You will find the command under DDL (on your left hand side panel)
http://msdn.microsoft.com/en-us/library/ms177570.aspx
http://msdn.microsoft.com/en-us/library/ms177570.aspx
http://www.mssqltips.com/sqlservertip/2646/using-a-ddl-trigger-to-block-schema-changes-in-sql-server/?utm_source=dailynewsletter&utm_medium=email&utm_content=headline&utm_campaign=2012328