从SQL存储过程导出文本文件 [英] Export a text file from a SQL Stored Procedure

查看:175
本文介绍了从SQL存储过程导出文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个当前进程存在于导出文本文件的2个MS Access数据库中。此过程在白天进行两次,一次在自动化过程中触发一段时间,第二次由应用程序前端的用户触发。



这两个数据库是一样的,现在我们将这个应用程序重写为SQL Server后端,c#winforms前端。理想情况下,我希望代码在一个地方执行此导出,所以如果我必须改变我只是改变一次。



新版本是使用SSIS包来调用早期自动进程的存储过程,然后对同一进程进行前端调用。



有没有办法从存储过程将数据导出到文本文件?



谢谢

解决方案

如果不想使用SSIS ,那么Phil Factor概述的方法可能会有用:



http://www.simple-talk.com/sql/t-sql-programming/the-tsql-of-text-files/

http://www.simple-talk.com/sql/t-sql-programming/reading-and-writing-files-in-sql-server-using-t -sql /



也就是说,通过使用平面文件作为数据流任务的目标,可以更容易地使用SSIS导出。 p>

I have a current process that exists in 2 MS Access databases that exports a text file. This process takes place twice during the day, once during a automated process that triggers at a set time and the second is triggered by a user on the front-end of the application.

This is identical in both databases and now we are rewriting this application to a SQL server backend, c# winforms front-end. Ideally I want the code to perform this export in one place so if I have to make a change I am only changing it once.

The new version of this is to use SSIS packages to call stored procedures for the morning auto process and then have a front-end call to the same process.

Is there a way to export data to a text file from a stored procedure?

Thanks

解决方案

If you don't want to use SSIS, then the methods outlined by Phil Factor may be of use:

http://www.simple-talk.com/sql/t-sql-programming/the-tsql-of-text-files/
http://www.simple-talk.com/sql/t-sql-programming/reading-and-writing-files-in-sql-server-using-t-sql/

That said, it is probably easier to use SSIS to export by using a Flat File as the destination for your Data Flow Task.

这篇关于从SQL存储过程导出文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆