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
 Deleted rows

Author  Topic 

lemondash
Posting Yak Master

159 Posts

Posted - 2008-10-23 : 08:34:16
Afternoon Guys/Girls

Would like to know if it is at all possible to do this.

I have a large table where rows/records get deleted throughout the day, but what I would like to do is track these deletes in some some way.

Maybe insert them in to another table, can this be done via trigger ? or does anybody have another idea ?

Regards Lee

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-10-23 : 08:49:53
Yes you do this via trigger. See sql server help file for syntax

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

lemondash
Posting Yak Master

159 Posts

Posted - 2008-10-23 : 08:56:56
Use this one ?

CREATE TRIGGER [ schema_name . ]trigger_name
ON { table | view }
[ WITH <dml_trigger_option> [ ,...n ] ]
{ FOR | AFTER | INSTEAD OF }
{ [ INSERT ] [ , ] [ UPDATE ] [ , ] [ DELETE ] }
[ WITH APPEND ]
[ NOT FOR REPLICATION ]
AS { sql_statement [ ; ] [ ,...n ] | EXTERNAL NAME <method specifier [ ; ] > }

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-23 : 09:33:53
Yes.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-23 : 10:15:59
quote:
Originally posted by lemondash

Use this one ?

CREATE TRIGGER [ schema_name . ]trigger_name
ON { table | view }
[ WITH <dml_trigger_option> [ ,...n ] ]
{ FOR | AFTER | INSTEAD OF }
{ [ INSERT ] [ , ] [ UPDATE ] [ , ] [ DELETE ] }
[ WITH APPEND ]
[ NOT FOR REPLICATION ]
AS { sql_statement [ ; ] [ ,...n ] | EXTERNAL NAME <method specifier [ ; ] > }




to add to this you need to use FOR or AFTER option for above case
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-23 : 10:25:34
Isn't that stated in the text copied from Books Online?
4th line?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -