I am using powershell to query a SQL table and then save the results in a file, this is working fine, however, the results are not stored in a matrix format but rather chunks.
How can I save the output like normal rows with separators tabs?
Invoke-Sqlcmd -ServerInstance "localhost" -Database "mydb" -InputFile "C:\Delivery.sql" | Out-File -filePath "C:\Delivery.txt
You should be using the Export-Csv
CmdLet to perform this action:
Invoke-Sqlcmd -ServerInstance "localhost" -Database "mydb" -InputFile "C:\Delivery.sql" |
Export-Csv -Path "C:\Delivery.txt