Hi all
I'm very noob in SQL. I work on a survey stuff.
I'd like to write a trigger that does:
when I remove a row of the result table, I get the session_id column of this row and check if there are still rows with this same session_id. If not, I remove this session_id of the session table.
Here is what I did so far:
I got this error: Error 0. Syntax error or access violation.
Can someone help me??
Thanks a lot ;-)
I'm very noob in SQL. I work on a survey stuff.
I'd like to write a trigger that does:
when I remove a row of the result table, I get the session_id column of this row and check if there are still rows with this same session_id. If not, I remove this session_id of the session table.
Here is what I did so far:
Code:
CREATE TRIGGER delete_session
ON result
{
after delete
as
declare @sid int
set sid = (select session_id from deleted)
if not exists ( sid )
begin
delete from session where session_id = sid
end
}
Can someone help me??
Thanks a lot ;-)