How to Resolve this Query [Resolved]

Posted by Jayakumars under Sql Server on 7/10/2015 | Points: 10 | Views : 1279 | Status : [Member] [MVP] | Replies : 1
hi

CREATE TABLE table1(
EmpId INT,
DeptId INT,
DeptName VARCHAR(30),
EmployeeName VARCHAR(30)
)

CREATE TABLE table2(
EmpId INT,
DeptId INT,
DeptName VARCHAR(30),
EmployeeName VARCHAR(30)
)


--- I have 2 tables when i Insert Table2 i need raise the trigger automatic insert table1
-- when i have insert table1 i need raise the trigger automatic insert table2

Mark as Answer if its helpful to you

Kumaraspcode2009@gmail.com



Responses

Posted by: Bandi on: 7/10/2015 [Member] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
GO
CREATE TRIGGER Tri_table1
ON Table1
FOR INSERT
AS
INSERT INTO table2 SELECT * FROM inserted
GO

CREATE TRIGGER Tri_table2
ON Table2
FOR INSERT
AS
INSERT INTO table1 SELECT * FROM inserted
GO

--To turn them off, type the following:

EXEC sp_configure 'nested triggers', 0
RECONFIGURE

insert into table1
values( 100, 10, 'IT', 'Chandu')

insert into table2
values( 200, 20, 'HR', 'AAA')


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response