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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Trigger to Drop the own Table

Author  Topic 

CLages
Posting Yak Master

116 Posts

Posted - 2006-03-08 : 07:29:50
Hi, I would like to make a Trigger in a Table MOVIMENT to Drop OR Truncate Itself

something like this


CREATE TRIGGER [DropTableMov] ON dbo.moviment
FOR INSERT
AS
IF (SELECT mov_trigger FROM INSERTED) = 'C'
Drop Table dbo.moviment;
or
Truncate Table dbo.moviment


is it Possible?

Tks

C. Lages

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2006-03-08 : 10:52:11
Triggers cannot modify the database schema.

And why in the WORLD would you want to do this?
Go to Top of Page

CLages
Posting Yak Master

116 Posts

Posted - 2006-03-10 : 06:40:18
the main idea was
if a table get too many rows, truncate its
and start again

C. Lages
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2006-03-10 : 10:43:42
Please don't do this.

This falls within the realm of database maintenance, not application logic. Use a scheduled job to delete old records.
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-03-10 : 10:57:35
quote:
Originally posted by CLages

the main idea was
if a table get too many rows, truncate its
and start again

C. Lages




If your data is that unimportant, just don't save it to begin with.



CODO ERGO SUM
Go to Top of Page
   

- Advertisement -