Monday, September 27, 2010

Trigger to avoid drop / alter tables by various logins

CREATE TRIGGER [Security]
ON DATABASE
FOR ALTER_TABLE, ALTER_PROCEDURE, DROP_TABLE, DROP_PROCEDURE, ALTER_TRIGGER, DROP_TRIGGER
AS
IF SYSTEM_USER NOT IN ('YadavA', 'BhandariD','groverv','mittals')
BEGIN
RAISERROR ('You do not have necessary permissions to perform this action! Contact the DBA for further help',10, 1)
ROLLBACK
END

GO

No comments: