[Solved] I want to insert a record in DB and then need to return a row
One way to do what you want is to modify @voucherNo to be an OUTPUT parameter, and add a new OUTPUT parameter to your query to return the value of SCOPE_IDENTITY(). @voucherNo varchar(max) @ScopeIdentity numeric(38,0) And modify that last SELECT statement to set the value of @ScopeIdentity parameter. SELECT @ScopeIdentity = SCOPE_IDENTITY() Then use SqlCommand.ExecuteNonQuery … Read more