简体   繁体   English

在Powershell ISE中格式化SQL输出

[英]Format SQL output in Powershell ISE

Using Invoke-SQLCMD and running a saved query, Is there a way to see the output as a table? 使用Invoke-SQLCMD并运行保存的查询,有没有办法将输出显示为表格? Currently, All output is printed sequentially, such as Name newline state newline is_encrypted for each item returned from the query rather than a row-column table where name, state, is_encrypted, etc. are the column headers. 当前,将按顺序打印所有输出,例如,对于从查询返回的每个项目,名称换行状态换行符 is_encrypted,而不是其中名称,状态,is_encrypted等是列标题的行列表。

The end goal is to output all the results of the query into a text or excel file. 最终目标是将查询的所有结果输出到文本或excel文件中。

尝试这个:

Invoke-Sqlcmd -query $sql | Export-Csv -Path c:\temp\excelfile.csv -NoTypeInformation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM