0

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

powershell output

henrycarteruk
  • 12,708
  • 2
  • 36
  • 40
David Garcia
  • 3,056
  • 18
  • 55
  • 90

1 Answers1

3

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
gvee
  • 16,732
  • 35
  • 50