Advertisement

04.05.2008 at 01:28PM PDT, ID: 23298740
[x]
Attachment Details

SQL Trigger on INSERT as well as UPDATE

Asked by MimUK in MS SQL Server, SQL Server 2005

Tags: Microsoft, SQL Server, 2005

I have the following Trigger which I cannot get to work on INSERT.
If I edit the record the trigger fires.

Please could someone point me in the right direction.

CREATE Trigger [dbo].[UpdateTerr] on [dbo].[Address]
for Update
as
begin
if update(addr_county)
begin
update Company set
            comp_secterr = case addr_county WHEN 'BUX' THEN '-805306364' WHEN 'SRY' THEN '-536870909' WHEN 'OFE' THEN '-805306364' WHEN 'SUX' THEN '-268435454' WHEN 'BRK' THEN '-1342177274' WHEN 'KNT' THEN '-1073741819' WHEN 'SXE' THEN '-268435454' WHEN 'SXW' THEN '-268435454' WHEN 'IOW' THEN '1' WHEN 'HPH' THEN '1' WHEN 'MK' THEN '-805306364' ELSE '134217728' end  
from inserted where Company.Comp_PrimaryAddressId = Inserted.Addr_AddressId              
end
end

I have tried changing it to for Insert, Update

Cheers.

MimStart Free Trial
[+][-]04.05.2008 at 01:34PM PDT, ID: 21289517

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.05.2008 at 01:40PM PDT, ID: 21289542

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.05.2008 at 01:50PM PDT, ID: 21289583

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.06.2008 at 11:49AM PDT, ID: 21292727

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.07.2008 at 07:20AM PDT, ID: 21297128

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MS SQL Server, SQL Server 2005
Tags: Microsoft, SQL Server, 2005
Sign Up Now!
Solution Provided By: mark_wills
Participating Experts: 2
Solution Grade: B
 
 
[+][-]04.07.2008 at 01:08PM PDT, ID: 21300122

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.07.2008 at 01:12PM PDT, ID: 21300145

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.07.2008 at 05:09PM PDT, ID: 21301590

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628