Good day. The task is to register and it is necessary to record the data and the pots to display the data. You need to do everything in 1 request. How to be?

  • one
    Options: 1. Trigger. 2. Stored function. 3. Stored procedure. 4. View to the stored function. 5. Another connection via ADO activex. Specify what you want. Or do you want to unsubscribe all 5 options? - nick_n_a
  • four
    Add OUTPUT docs.microsoft.com/en-us/sql/t-sql/queries/… to your request - Mike
  • @nick_n_a if you can, then all 5 - elik
  • 3
    You have already tried output, it does not suit you with something? insert into token output inserted.* values(...) - Mike
  • 2
    Ummm What it means to show the implementation, this is a ready-made query, it remains only to substitute the name of the table, columns and inserted values - Mike

1 answer 1

You need to use OUTPUT in your insert request.

Extract from the documentation for SQL Server, the full text can be read on the link

OUTPUT (Transact-SQL) Clause:

Returns data from rows that have changed as a result of an INSERT, UPDATE, DELETE, or MERGE statement, or an expression based on this data. These results can be returned to the application, for example, to display confirmation messages, archiving, etc. The results can also be inserted into a table or table variable. In addition, you can write the results of an OUTPUT clause in nested INSERT, UPDATE, DELETE, or MERGE statements and insert these results into the target table or view.