I need to run 4 update queries via powershell, so I did some googling to try to find the answer. This is the syntax that I was able to come up with, but it is giving me an error, so I assume I didn't set something up properly. Can someone help me get this code functioning properly?
$sql=@'
UPDATE firefly.light.dbo.shipped SET shipped = 'Yes' WHERE shippingstatus IN ('Loading', 'Shipped')
UPDATE firefly.light.dbo.inventorystatus SET orderitem = 'Yes' WHERE Count(item) < '3'
UPDATE firefly.light.dbo.stockinformation SET verify = 'Yes' WHERE Count(item) = '0'
UPDATE firefly.light.dbo.orderinformation SET verify = 'Yes' WHERE status NOT IN ('Shipped', Back Order', 'Pending')
'@
#Setting Server Information
$server='Powerball'
$dbname='hero6'
$connStr='Server={0};Database={1};Integrated Security=SSPI;' -f $server,$dbname
$conn=New-Object System.Data.SqlClient.SQLConnection($connStr)
$conn.Open()
$cmd=$conn.CreateCommand()
$cmd.CommandText=$sql
$i=$cmd.ExecuteNonQuery()
Write-Host "Records Affected: $i" -fore green