ALTER PROCEDURE some_proc @insert_val nvarchar(15), @out_result nvarchar(20) OUT AS INSERT INTO some_table (one_row) VALUES (@insert_val) 

I don’t know how to get the result of an INSERT and write it to @out_result .

  • What specific execution result do you want to record? - sp7
  • let's say the int field has written a string and so on. In general, any result, find out the record went or not - Alimzhan Aitikenov

2 answers 2

It is not entirely clear what is meant by the result of the execution of insert, but if we assume that you want to get only the fact of the record passing, you can write with the last line:

 select @out_result = @@rowcount 

This system variable returns the number of rows used in the previous query, in the case of correct insertion it will have the value 1.

    Result? You pass it by parameter. I understand this is the same value. If you want to use it further, use OUTPUT. The result of the execution will be retun value=@out_result. If you want to log, you can continue the procedure by re-inserting it into another table.