SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Trigger in 2008
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

lamine
Starting Member

1 Posts

Posted - 04/30/2013 :  10:44:43  Show Profile  Reply with Quote
I would like to have an AFTER UPDATE, INSERT Trigger.
I have two tables:

Jobs has three fields; JobsId, JobsName, JobsArea
JobsLink has three fields; JobsLinkId, JobsLinkJobsId, JobsLinkCalculation.

The two tables are linked ON Jobs.JobsId = JobsLink.JobsLinkJobsId

What I want is? If I update Jobs table or insert a new records in it, I want it to update or insert a records in JobsLink where JobsLinkCalculation field will simply have JobsName + '-' + JobsArea from jobs table.

Please help.
Cheers
L

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 05/02/2013 :  01:39:15  Show Profile  Reply with Quote

CREATE TRIGGER Trg_CreateJobLink ON Jobs
AFTER INSERT
AS
BEGIN

INSERT JobsLink(JobsLinkJobsId, JobsLinkCalculation)
SELECT JobsId,JobsName + COALESCE('-' + JobsArea ,'')
FROM INSERTED

END


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000