简体   繁体   English

SQL将数据导出到文件

[英]SQL exporting data to a file

I'm trying to setup a job to export data to a file. 我正在尝试设置作业以将数据导出到文件。 The query for this is also in the job. 该查询也在工作中。 It produces a temporary table called "temp_tickets". 它产生一个称为“ temp_tickets”的临时表。

That works. 这样可行。

Now I want to write the data to a file. 现在,我想将数据写入文件。 I have this line for that: 我有这行:

EXEC master..xp_cmdshell 'bcp esi_db.dbo.temp_tickets out D:\Websites\enn-portal\temp\esitdata.csv -f D:\Websites\enn-portal\XML\esittickets.xml -T'

The file is created, but is remains empty. 文件已创建,但仍为空。

I have also tried it without the format file, but same result. 我也尝试过不使用格式文件,但结果相同。

What is going wrong? 怎么了?

I have used this method on an other job and it works there, so why not here? 我已经在其他工作上使用了这种方法,并且可以在那工作,所以为什么不在这里呢?

rg. rg。 Eric 埃里克

Managed to find the error by executing the bcp line in a regular query window instead of in the sql server agent step. 通过在常规查询窗口中而不是在sql server agent步骤中执行bcp行来查找错误。

It provided me with some error data that helped me solve the problem (the format file was not right). 它为我提供了一些错误数据,可以帮助我解决问题(格式文件不正确)。

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

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