I am running an insert query from c# using:
string affectedRows = myCommand.ExecuteNonQuery().ToString();
However the query that I am running does two things. It first inserts stuff into a temp table, and then inserts stuff into the real-table.
Eg:
declare @t table (a int)
insert into @t
values(1)
insert into MyTable
select * from @t
Since it does two inserts, my affectedrows will be 2.
The question is how to i get either the last result of the insert, or perhaps an array/list of results?
Dividing by 2 won’t help me, as there maybe multiple queries, etc and it won’t always be 2. the above is just an example. Thanks
Just change the SET NOCOUNT statement to view the lines that really matter:
example:
See the Messages tab in SSMS.