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
 Updation in SQL using a Trigger

Author  Topic 

abi
Starting Member

6 Posts

Posted - 2008-11-14 : 08:45:19
Hi friends

I'm new to SQL

I have two tables in a server(amschn and amsggn).
amschn has got four fields(ecode,day,in_time,out_time)
amsggn has got five fields(ecode,day,in_time,out_time,status)

I want to write a trigger such as when
there is a insert/update(entry) in amschn(in_time) it should update the 'status' field in amsggn as present.

Please help me

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-14 : 08:55:24
[code]CREATE TRIGGER yourtrigger ON
amschn
FOR INSERT,UPDATE
AS

IF UPDATE(in_time)
UPDATE t
SET t.status='present'
FROM amsggn t
INNER JOIN INSERTED i
ON i.ecode=t.ecode

GO[/code]
Go to Top of Page
   

- Advertisement -