So I have a small Powershell script that is opening an Excel file for import into MSSQL.
Because of the MSSQL schema, I'll need to insert the data in pieces, capture the inserted ID, and use that ID in future insert statements.
So, if I have my first statement e.g. "INSERT INTO xx (..) OUTPUT inserted.ID [...]", how, in Powershell, do I capture the results of that output clause?
Currently using:
$cmd=new-object system.Data.SqlClient.SqlCommand($sql,$conn)
return $cmd.ExecuteNonQuery()
but I want to capture the output clause, so my default will likely change to whatever is needed for this capture.