Export a text file from a SQL Stored Procedure
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 trig开发者_运维问答gers 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.
精彩评论