Click to See Complete Forum and Search --> : SQL Server Trigger to truncate other table


legendx
10-11-2007, 04:39 PM
I'm trying to set up a trigger on a news table that will truncate my cache table. However whenever I run an update on the news table it gives me an SQL error. It doesn't tell me what the error is.. just that it failed.

Here is the trigger I created:

CREATE trigger flush_cache on news
for update
as

truncate table cache


When I delete the trigger the exact same update query runs fine with no errors. What am I doing wrong?

BTW this is SQL Server 2005

russell
10-17-2007, 04:12 PM
error message should show in the messages tab of SSMS. how are u executing query?

make sure that the table you are trying to truncate is not referenced by any foreign keys.

tried executing the truncate in ssms?