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
 General SQL Server Forums
 New to SQL Server Programming
 New to triggers - Deleted Folder Trigger

Author  Topic 

unikoman
Starting Member

32 Posts

Posted - 2006-07-04 : 18:57:57

Hi

I would like to know how can I write a trigger for a table that lists folders deleted. I have a table called RECORDS which contains folders and would like to know folders that are being deleted.

Thanks...

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-07-04 : 19:01:20
You can create a delete trigger on the table and in the trigger, insert the deleted records into another table (Audit Trail table)

create trigger td_RECORDS on RECORDS for delete as
begin

insert into RECORDS_AUDIT( . . .)
select . . .
from deleted
end



KH

Go to Top of Page

unikoman
Starting Member

32 Posts

Posted - 2006-07-04 : 19:11:42
thanks I'll try that
Go to Top of Page

unikoman
Starting Member

32 Posts

Posted - 2006-07-11 : 08:20:14
ok, thanks that works.....
Just one more question on this, is it possible to apply atrigger on a entire database, accross all tables? or is there a better way to do this ?
Go to Top of Page

unikoman
Starting Member

32 Posts

Posted - 2006-07-11 : 08:25:45
opps what I meant is id a query to list all deleted folders can be applieed to the entire database? instead of single tables...
Go to Top of Page

unikoman
Starting Member

32 Posts

Posted - 2006-07-12 : 23:55:43
can someone help me please, is it possible to apply a trigger like the one above accross all database tables or not? or do I need to create every for every time i need?

thanks
Go to Top of Page

unikoman
Starting Member

32 Posts

Posted - 2006-07-12 : 23:56:43
i mean create one for every table that needs one...
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-07-13 : 00:19:24
You have to create one for each table that you required this.


KH

Go to Top of Page

unikoman
Starting Member

32 Posts

Posted - 2006-07-13 : 01:04:46
thanks:)
Go to Top of Page
   

- Advertisement -