Using SQL DataReader to capture inserted or deleted values

I am currently invoking a stored procedure from a .net application that inserts records into a database. However, I need to get a list of the records I just inserted.

I know that I could directly return the inserted rows from a stored procedure, but I was hoping there was a way to do this programmatically in C #.

Is it possible to implement the SQLDataReader class to achieve this functionality, i.e. reading from inserted / deleted tables? Or is there some other class that can satisfy this request?

+6
source share
1 answer

Insert / delete tables are available in the OUTPUT clause of the INSERT statement. You can use the OUTPUT clause in INSERT in your stored procedure and use SQLDataReader to get the result.

+3
source

Source: https://habr.com/ru/post/916060/


All Articles