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
 Database trigger for updating the records

Author  Topic 

aoriju
Posting Yak Master

156 Posts

Posted - 2012-02-17 : 02:54:45
Hi All,

I am looking for a database trigger for updating the some of my tables

condition is : i have a table (table1) and field like status
through my application i will update various status and corresponding dates

when status is 3 i want to update & insert some tables based on after 3 days of status updation like 3

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-17 : 13:45:02
something like

CREATE TRIGGER MyTrigg
ON Table
AFTER UPDATE
AS
BEGIN
UPDATE t
SET columns = value....
FROM INSERTED i
JOIN yourtable t
ON t.col = i.Col
WHERE i.status = 3

INSERT INTO table
SELECT columns...
FROM INSERTED i
JOIN yourtable t1
ON t1.col = i.Col
WHERE i.status = 3

END


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -