|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Friday, December 11, 2009 5:20 AM
Points: 78,
Visits: 35
|
|
Hi!
I want Update one table when in another table insert new record .I didn't understand how i get this new inserted ID.
Regards Gouri
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, January 26, 2012 5:26 AM
Points: 1,367,
Visits: 1,585
|
|
gouripatil23 (1/11/2008) Hi!
I want Update one table when in another table insert new record .I didn't understand how i get this new inserted ID.
Regards Gouri Hi Gouri,
In the trigger body you have access to two virtual tables, inserted and deleted. These contain the data about the rows that you have inserted (or deleted/modified). You can update the table you wish based on the inserted table. See http://msdn2.microsoft.com/en-us/library/ms189799.aspx
Regards, Andras
Andras Belokosztolszki, MCPD, PhD GoldenGate Software
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, July 23, 2010 6:54 AM
Points: 1,
Visits: 1
|
|
The below code may help u in finding ur problem
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= ALTER TRIGGER [dbo].[Insert_Trg_Dept] ON [dbo].[Dept] AFTER INSERT AS BEGIN SET NOCOUNT ON; DECLARE @EMPID INT, @DEPTID INT, @DEPTNAME VARCHAR(50)
SELECT @EMPID=EMPID FROM EMPLOYEE INSERT INTO DEPT VALUES(@DEPTNAME,@DEPTID,@EMPID)
END
|
|
|
|