Translate

Thursday, 27 November 2014

DDL trigger for no new table in sql server

create database demo
create trigger NoTable
on database
for CREATE_TABLE
AS BEGIN
PRINT 'NO NEW TABLE PLEASE'
ROLLBACK
END
------------------------------------

------------
After executing trigger NoTable
then run 
CREATE TABLE EMPPP(ID INT, NAME VARCHAR(50))
---------
the result will be
------------
NO NEW TABLE PLEASE
Msg 3609, Level 16, State 2, Line 1
The transaction ended in the trigger. The batch has been aborted.

No comments:

Post a Comment