【问题标题】:Invoke-sqlcmd - to export the output of a sql query to an xml file using powershellInvoke-sqlcmd - 使用 powershell 将 sql 查询的输出导出到 xml 文件
【发布时间】:2013-09-11 12:08:17
【问题描述】:

我有一个带有 for xml 显式子句的 sql 查询。结果我需要存储在一个 xml 文件中。 我正在使用 powershell 命令来执行此操作: 调用-sqlcmd -inputFile $inputFilePath |输出文件 -filePath $outputFilePath

这给了我一个类似于

的输出文件

XML_F52E2B61-18A1-11d1B1000805F49916B

'dsugfiugds'

'sdgfdg'45'

ss>sdfsdfsfd<....>

这个文件也被截断了,你可以看到...出现了 我需要 xml 的格式正确,即 xml 文件本身。

【问题讨论】:

  • 查询输出的是 XML 还是常规数据表?

标签: sql-server xml powershell for-xml


【解决方案1】:

您是否尝试过 Export-Clixml 而不是 Out-File?

 invoke-sqlcmd -inputFile $inputFilePath | Export-Clixml -filePath $outputFilePath

【讨论】:

    猜你喜欢
    • 2021-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-17
    • 1970-01-01
    • 1970-01-01
    • 2019-06-21
    • 1970-01-01
    相关资源
    最近更新 更多