CREATE TRIGGER test ON A FOR UPDATE AS BEGIN INSERT INTO B ( B0 , B1 , B2 ) SELECT ( SELECT MAX(B0) FROM B ) + 1 , A1 , A2 FROM Inserted WHERE A1 = 'zdjs' END
CREATE TRIGGER test ON C FOR UPDATE AS BEGIN INSERT INTO A ( A1 , A2 , A4 ) SELECT C1 , ( SELECT MAX(A2) FROM A ) + 1 , C4 FROM Inserted WHERE C4 = 'zdjs'
INSERT INTO B ( B1 , B2 , B3 , B5 , B6 , B7 ) SELECT C1 , ( SELECT MAX(A2) FROM A )+1 , C3 , C5 , D6 , D7 FROM Inserted JOIN D ON C1 = D1 AND C2 = D2 AND C3 = D3 WHERE C4 = 'zdjs' END
CREATE TRIGGER test ON C FOR UPDATE AS BEGIN INSERT INTO A ( A1 , A2 , A4 ) SELECT C1 , ( SELECT MAX(A2) FROM A ) + 1 , C4 FROM Inserted WHERE C4 = 'zdjs'
INSERT INTO B ( B1 , B2 , B3 , B5 , B6 , B7 ) SELECT C1 , ( SELECT MAX(A2) FROM A )+1 , C3 , C5 , D6 , D7 FROM Inserted JOIN D ON C1 = D1 AND C2 = D2 AND C3 = D3 WHERE C4 = 'zdjs' END
CREATE TRIGGER test ON A FOR UPDATE AS BEGIN INSERT INTO B ( B0 , B1 , B2 ) SELECT ( SELECT MAX(B0) FROM B ) + 1 , A1 , A2 FROM Inserted WHERE A1 = 'zdjs' END
#2
试试这个
CREATE TRIGGER test ON A FOR UPDATE AS BEGIN INSERT INTO B ( B0 , B1 , B2 ) SELECT ( SELECT MAX(B0) FROM B ) + 1 , A1 , A2 FROM Inserted WHERE A1 = 'zdjs' END
CREATE TRIGGER test ON C FOR UPDATE AS BEGIN INSERT INTO A ( A1 , A2 , A4 ) SELECT C1 , ( SELECT MAX(A2) FROM A ) + 1 , C4 FROM Inserted WHERE C4 = 'zdjs'
INSERT INTO B ( B1 , B2 , B3 , B5 , B6 , B7 ) SELECT C1 , ( SELECT MAX(A2) FROM A )+1 , C3 , C5 , D6 , D7 FROM Inserted JOIN D ON C1 = D1 AND C2 = D2 AND C3 = D3 WHERE C4 = 'zdjs' END
CREATE TRIGGER test ON C FOR UPDATE AS BEGIN INSERT INTO A ( A1 , A2 , A4 ) SELECT C1 , ( SELECT MAX(A2) FROM A ) + 1 , C4 FROM Inserted WHERE C4 = 'zdjs'
INSERT INTO B ( B1 , B2 , B3 , B5 , B6 , B7 ) SELECT C1 , ( SELECT MAX(A2) FROM A )+1 , C3 , C5 , D6 , D7 FROM Inserted JOIN D ON C1 = D1 AND C2 = D2 AND C3 = D3 WHERE C4 = 'zdjs' END
CREATE TRIGGER test ON C FOR UPDATE AS BEGIN INSERT INTO A ( A1 , A2 , A4 ) SELECT C1 , ( SELECT MAX(A2) FROM A ) + 1 , C4 FROM Inserted WHERE C4 = 'zdjs'
INSERT INTO B ( B1 , B2 , B3 , B5 , B6 , B7 ) SELECT C1 , ( SELECT MAX(A2) FROM A )+1 , C3 , C5 , D6 , D7 FROM Inserted JOIN D ON C1 = D1 AND C2 = D2 AND C3 = D3 WHERE C4 = 'zdjs' END
CREATE TRIGGER test ON C FOR UPDATE AS BEGIN INSERT INTO A ( A1 , A2 , A4 ) SELECT C1 , ( SELECT MAX(A2) FROM A ) + 1 , C4 FROM Inserted WHERE C4 = 'zdjs'
INSERT INTO B ( B1 , B2 , B3 , B5 , B6 , B7 ) SELECT C1 , ( SELECT MAX(A2) FROM A )+1 , C3 , C5 , D6 , D7 FROM Inserted JOIN D ON C1 = D1 AND C2 = D2 AND C3 = D3 WHERE C4 = 'zdjs' END