Exporting query results to a file on the fly

Posted by ercan on Stack Overflow See other posts from Stack Overflow or by ercan
Published on 2010-04-22T08:43:47Z Indexed on 2010/04/22 13:03 UTC
Read the original article Hit count: 305

Hi all,

I need to export the results of a query to a csv file in an FTP folder.

  1. Is it possible to achieve this within a stored procedure?
  2. If yes, comes yet another constraint: can I achieve this without sysadmin privileges, aka without using xp_cmdshell + BCP utility?
  3. If no to 2., does the caller have to have sysadmin privileges or would it suffice if the SP owner has sysadmin privileges?

Here are some more details to the problem: The SP must export and transfer the file on the fly and raise error if something went wrong. The caller must get a response immediately, i.e. in case of no error, he can assume that the results are successfully transferred to the folder. Therefore, a DTS/SSIS job that runs every N minutes is not an option. I know the problem smells like I will have to do this at application level, but I would be more than happy if all those stuff could be done from T-SQL.

© Stack Overflow or respective owner

Related posts about sql

Related posts about tsql