Hi,
SQL Server 2005
I've read through existing posts and used bits & pieces. Think I've got something close.
When an Insert occurs on TABLE_A I want to perform an Insert on TABLE_B.
I want to take TABLE_A.Value1 and insert it into new record TABLE_B.Value1.
I also want to insert the value "Leased" into TABLE_B.Value2.
There is also a where clause which ensures the Trigger only fires for records where TABLE_A.Field3 = 400001
The records are joined on TABLE_A.Value1 and TABLE_B.Value1
This is my trigger;
SQL Server 2005
I've read through existing posts and used bits & pieces. Think I've got something close.
When an Insert occurs on TABLE_A I want to perform an Insert on TABLE_B.
I want to take TABLE_A.Value1 and insert it into new record TABLE_B.Value1.
I also want to insert the value "Leased" into TABLE_B.Value2.
There is also a where clause which ensures the Trigger only fires for records where TABLE_A.Field3 = 400001
The records are joined on TABLE_A.Value1 and TABLE_B.Value1
This is my trigger;
Code:
USE [mdb]
GO
/****** Object: Trigger [dbo].[TR_DF_ci_hardware_workstation] Script Date: 01/12/2009 05:00:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[TR_DF_ci_hardware_workstation]
ON [dbo].[TABLE_A] AFTER INSERT
AS
BEGIN
UPDATE dbo.TABLE_B
SET dbo.TABLE_B.Value2 = 'Leased'
WHERE TABLE_A.Value3 = 400001
AND
TABLE_B.Value1 IN
(
SELECT TABLE_B.Value1
FROM Inserted
)