Hello! Tell me, is it possible to implement such a thing in mssql 2016, when adding records to one table, certain fields were displayed in another table? I would be very grateful for the help, advice, link.

  • @ nzeemin, let's say there are 2 tables 1) Arrival log (Name of the part, name of the Supplier, price of the part, quantity, amount, date of receipt) 2) Warehouse (material, quantity) and so, when adding an entry to table "1", in the table "2" was filled with material and its quantity. Like that. - Sergey74rus

1 answer 1

Most likely, you need to use the trigger on INSERT: https://msdn.microsoft.com/ru-ru/library/ms189799(v=sql.120).aspx

UPDATE But in this wording

Let's say there are 2 tables 1) Incoming log (Name of the part, name of the Supplier, price of the part, quantity, amount, date of receipt) 2) Warehouse (material, quantity) and so, when adding a record to the table "1", in the table "2" filled with material and its quantity. like that

- in this version, I would have done the INSERT two times better - to the Arrival Log table and the Warehouse table. The reason is that the trigger on the INSERT always works. Suppose you need to import entries into the Arrival Log or insert test entries - the trigger will still work.

  • and triggers need to be connected to visualStudio C #, such as a stored procedure, or not? - Sergey74rus