Click here to Skip to main content
15,894,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,


i want write trigger on sys.database table in which
one colum name state_desc is change when one of database in suspect/ file recovery mode.


i want event when value of table and colum state_desc change on that event i will perform my other operation.
Posted
Updated 23-Feb-15 2:27am
v2

1 solution

It really isn't advisable to moderate system tables, in any way. Your trigger or any other addition could cause undesired behaviour and whenever a patch or service pack is applied to the SQL Server your modifications may disappear. Because of these reasons modifications to system owned objects are not allowed by default.

If you intend to create a trigger own your own table then you have defined a wrong table in the CREATE statement. Should it be something like:
SQL
CREATE TRIGGER TriggeredSuspect on MyTableNameGoesHere
INSTEAD of Update
AS declare @empname varchar(55), @empAdd varchar(55), @audit_action varchar(100);
select @empname='Suspect'
select @empAdd='Suspect'
set @audit_action='Inserted Record -- After Insert Trigger.';
insert into [TestDB].dbo.employee(emp_name,emp_add)
values (@empname,@empAdd);
PRINT 'AFTER INSERT trigger fired.'
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900