The code below in powershell will insert into a SQL Server table like
a aa aaa | b bb bbb
in one row, but I want
a | b aa | bb aaa | bbb
on 3 separate rows.
$Connection = New-Object System.Data.SQLClient.SQLConnection
$Connection.ConnectionString =
"server='$Server';database='$Database';trusted_connection=true;"
$Connection.Open()
$stringA = 'a', 'aa', 'aaa'
$stirngB = 'b', 'bb', 'bbb'
for ($i = 0; $i -lt 3; $i++) {
$sql = "INSERT INTO [dbo].[Server] (ServerName, UniqueID)
VALUES ('$stringA[$i]','$stringB[$i]')"
$Command.CommandText = $sql
$Command.ExecuteReader()
}
$Connection.Close()
How can I manipulate my code to insert into 3 separate rows instead of 1 row?