powershell iSe中格式SQL输出



使用Invoke-SQLCMD并运行保存的查询,是否有办法将输出视为表?当前,所有输出均顺序打印,例如Newline newline state newline is_encrypted for从查询返回的每个项目,而不是划分表,name,state,state,istate,istate,istate,istate,is_centerpted,is_centperted,is_cented,is_encrypted,等是列标题。

最终目标是将查询的所有结果输出到文本或Excel文件中。

尝试以下:

Invoke-Sqlcmd -query $sql | Export-Csv -Path c:tempexcelfile.csv -NoTypeInformation

最新更新