insert trigger
-
i want to create a trigger to copy value inserted to another column on another table i have tried the following but failed. invoice_summary >> table to copy from Invoice_details >> table to copy to create trigger Insert_InvoiceNum on dbo.invoice_summary for insert AS begin insert into Invoice_details select Invoice_num from inserted go regards
-
i want to create a trigger to copy value inserted to another column on another table i have tried the following but failed. invoice_summary >> table to copy from Invoice_details >> table to copy to create trigger Insert_InvoiceNum on dbo.invoice_summary for insert AS begin insert into Invoice_details select Invoice_num from inserted go regards
-
error Server: Msg 170, Level 15, State 1, Procedure Insert_InvoiceNum, Line 5 Line 5: Incorrect syntax near 'inserted'.
-
I suspect your InvoiceDetails table has more than 1 column so you need to specify why column to insert the value to
insert into Invoice_details**(Invoice_num)** select Invoice_num from inserted
Bob Ashfield Consultants Ltd
-
i want to create a trigger to copy value inserted to another column on another table i have tried the following but failed. invoice_summary >> table to copy from Invoice_details >> table to copy to create trigger Insert_InvoiceNum on dbo.invoice_summary for insert AS begin insert into Invoice_details select Invoice_num from inserted go regards
Try placing an end before the "go". Each time you have a BEGIN, you need an END.
--------------------------- Blogging about SQL, Technology and many other things
-
Try placing an end before the "go". Each time you have a BEGIN, you need an END.
--------------------------- Blogging about SQL, Technology and many other things
it succeeded but the insert value affected all rows i want it to affect 1 row only (new row) hers is trigger syntax create trigger InsertInvoice on dbo.Invoice_Summary for insert As begin insert into Invoice_details.Invoice_num select Invoice_num from Inserted end go example : insert into invoice_summary (P_name) values ('N1') results: the row insert to invoice_summary with Invoice_num 80 problem : all invoice numbers in the invoice_details(invoice_num) is 80 should 1 row only added with that value regards
-
Try placing an end before the "go". Each time you have a BEGIN, you need an END.
--------------------------- Blogging about SQL, Technology and many other things