如何导出超过1MB的XML格式使用sqlcmd和没有输入文件? [英] How to export more than 1MB in XML format using sqlcmd and without an input file?
问题描述
在SQL Server 2008中,我想使用 sqlcmd 实用程序将存储过程的结果导出到文件。现在我的存储过程的结尾是一个带有for xml path ..子句的select语句。
In SQL Server 2008, I want to export the result of a stored procedure to a file using sqlcmd utility. Now the end of my stored procedure is a select statement with a "for xml path.." clause at the end.
我在 BOL ,如果我不希望在达到1MB文件大小时截断输出,我必须使用这个:XML ON 命令,但是在调用存储过程之前应该放在自己的行上。
I read on BOL that if I don't want my output truncated when reaching 1MB file size, I have to use this :XML ON command, but it should be placed on its own line, before calling the stored procedure.
- 您是否有专家知道如果可以这样做,而不指定sqlcmd的输入文件? (我正在这样调用sqlcmd:
exec master..xp_cmdshell'sqlcmd -Qexec storedProcedureName @ param1 = value1,@ param2 = value2-oc:\exportResults.xml -h-1 -E'
,
storedProcedureName,其参数可以更改,这意味着每个传递参数到sqlcmd的1个输入文件)
but "storedProcedureName" and its parameters can change, which would mean 1 input file per passed parameters to sqlcmd)
- 此外,似乎我可以' t使用bcp而不是sqlcmd,因为我的存储过程是创建一个临时表并在其上执行DML语句?
非常感谢
推荐答案
我回答我的问题(使用powershell):
I answer my question (using powershell):
这篇关于如何导出超过1MB的XML格式使用sqlcmd和没有输入文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!