Exporting to Text File

  • I need to export data to a text file within a Stored Procedure.

    The file name and location is always the same.

    The text file needs to be replaced with the new result set.

    I do not know C# or VB.NET, so CLR may not be an option for me.

    Currently, I use the following command. However, we are eliminating xp_cmdshell.

    EXEC master..xp_cmdshell 'bcp "SELECT * FROM tblTable" queryout \\Server\Folder\FileName.txt -T -c'

    Thank you very much!

  • Use SSIS

  • Elaborating on Ray's reply...

    You could create an SSIS Package and then you could call that from the stored procedure, by various means... using XP_Cmdshell, usign TSQL to add it to a job in the SQL Agent que etc.

    There are various articles on the very subject on this site. Another reference you could use would be BOL or SQLdts.com

    -Luke.

    To help us help you read this[/url]For better help with performance problems please read this[/url]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply