【发布时间】:2014-09-05 16:44:16
【问题描述】:
尝试将 SQL Server 数据库查询结果导出到 .csv 文件,根据 here 显示的内容,我有类似的输出情况,但我用不同的方法打开了一个新线程。
我有一个复杂的查询,它通过一些临时表使用一些过滤器连接了几个表。我正在执行存储过程:
EXEC xp_cmdshell 'SQLCMD -S . -d myDATABASE -Q "EXECUTE myStoreProcedure;" -s " " -x -o "d:\result.csv"';
我将所有数据放入 result.csv 但文件开头包含一些数据
(10 rows affected)
(4 rows affected)
(23 rows affected)
(5 rows affected)
(8 rows affected)
(2 rows affected)
//followed by the header columns - as expected
----------------------------------------------------------------------
//and effective results - as expected
我宁愿没有输出和虚线行。我愿意接受任何建议/解决方法。
【问题讨论】:
-
你可以在它之前尝试
Set NoCount On,但我相信它可能仍然有虚线。 -
没错,这正在发生。我还有虚线行。
标签: sql sql-server csv export-to-csv