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)
 How to write a trigger?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-04-04 : 07:59:40
Dan writes "So, I have read the books online for triggers....

And googled for 45 minutes now and still can't figure out how to write a trigger statement the way I want to.

How do I get the bloody case_number so I can insert it into the case times_table?

And (Case_Number,Start_Time) VALUES (Case_Number, getdate()) doesn't seem to work like it does for an update statement.

CREATE TRIGGER [Time_Tracker] ON [dbo].[cases]
FOR INSERT, UPDATE, DELETE
AS
IF UPDATE (Case_Number) or UPDATE (Mod_Time)
BEGIN

INSERT INTO Case_Times
(Case_Number,Start_Time) VALUES ('8885', getdate())
END"

nr
SQLTeam MVY

12543 Posts

Posted - 2005-04-04 : 08:01:44
Have a look at the inserted and deleted tables (just the inserted in this case).
http://www.mindsdoor.net/SQLTriggers/Triggers_1_A_beginners_guide.html

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -