Create Trigger
-
hi dearest brothers/sisters i have created trigger in MSSQL SERVER. CREATE TRIGGER IDx on Table2 after INSERT AS insert into Table2 (RefNo) select RefNo from Table1 i need Table2 Foreign key RefNo to be filled no of times which means eg. table2 may need RefNo to be filled in three rows. currently i get single row others kept NULL values help me plz thanks
so much of happy ending...
-
hi dearest brothers/sisters i have created trigger in MSSQL SERVER. CREATE TRIGGER IDx on Table2 after INSERT AS insert into Table2 (RefNo) select RefNo from Table1 i need Table2 Foreign key RefNo to be filled no of times which means eg. table2 may need RefNo to be filled in three rows. currently i get single row others kept NULL values help me plz thanks
so much of happy ending...
try this Overview of SQL Server database Triggers[^]
-
hi dearest brothers/sisters i have created trigger in MSSQL SERVER. CREATE TRIGGER IDx on Table2 after INSERT AS insert into Table2 (RefNo) select RefNo from Table1 i need Table2 Foreign key RefNo to be filled no of times which means eg. table2 may need RefNo to be filled in three rows. currently i get single row others kept NULL values help me plz thanks
so much of happy ending...
Triggers are EVIL. Although this is a valid use of a trigger I would suggest using a normal stored proc and surrounding the inserts with a transaction. Begin Tran insert parent record get scope_identity for the inserted record begin a loop insert the number of records in the child tables end the loop commit the transaction return the id to the calling method
Never underestimate the power of human stupidity RAH
-
Triggers are EVIL. Although this is a valid use of a trigger I would suggest using a normal stored proc and surrounding the inserts with a transaction. Begin Tran insert parent record get scope_identity for the inserted record begin a loop insert the number of records in the child tables end the loop commit the transaction return the id to the calling method
Never underestimate the power of human stupidity RAH