C#C
C#3y ago
Zil

Returning a value after a insert statement

This is the code im running in DotNet:
c++
var testQuery = $@"
  INSERT INTO [{databaseName}].[dbo].[steptable] ([Type], [ParentKey], [SubWorkflowCode], [Sequence], [WorkflowKey]) 
  OUTPUT inserted.[Key]
  VALUES (@Type, CASE WHEN @ParentKey = 0 THEN NULL ELSE @ParentKey END, @SubWorkflowCode, @Sequence, @WorkflowKey);";

var test = await connection.ExecuteAsync(testQuery, step);

After execution the var test contains 1. When i run the same sql statement in mssql the result can be seen in the attached image.
I think the 1 comes from the row number, but i need the 441 to be returned into the test variable.

Thanks in advance!
image.png
Was this page helpful?