Author Posts

March 22, 2017 at 2:25 am

Say I have a list of values in $result. I need to loop through and insert the all the values in a table(already created) in mssql through an SMO connection. Could you help me with the script?

March 23, 2017 at 12:28 pm

Sure. Use a ForEach loop to loop through $result.

ForEach ($thing in $result) { }

Then fire off your INSERT statements. In this case, you can use $thing to construct query strings. I don't use SMO (I tend to just use .NET's SqlClient classes), so hopefully you know how to do that in SMO.