Formatting powershell SQL Server output into columns and rows

后端 未结 2 367
不思量自难忘°
不思量自难忘° 2021-01-27 14:44

I\'m a beginner with Powershell trying to query a SQL Server database and output the csv in a file organised rows and columns. I can partially achieve this with the following co

2条回答
  •  Happy的楠姐
    2021-01-27 15:24

    I think what you are looking for is the -NoTypeInformation switch.

    $results | export.csv $FilePathOfCSV -NoTypeInformation
    

    -NoTypeInformation is a switch that omits type information from the outputted CSV file. The first line of the CSV contains the type followed by the full name of the .NET framework object it is using.

    That should give you a structured CSV output.

    Hope it works!

提交回复
热议问题