Results 1 to 3 of 3

Thread: BCP To CSV

  1. #1
    Join Date
    Feb 2012

    Unanswered: BCP To CSV

    I have the basic syntax for BCP to a CSV file down. I have 2 ?'s regarding this procedure.
    1) is it possible to copy header text (meaning field names?
    2) is it possible to delete the file once it has been attached to an email?

  2. #2
    Join Date
    Jan 2003
    Provided Answers: 17
    As long as your header information is static, then you can have the header information in a single file, and "prepend" the header information on the data file (you will end up doubling the data file size, of course. You just need to make sure that the header file ends with a new line character:
    C:\>echo This is a dummy header > test1.txt
    C:\>echo And this is dummy data > test2.txt
    C:\>type test1.txt, test2.txt > test3.txt
    C:\>notepad test3.txt
    Deleting the file after it has been attached to an email, depends on how you get confirmation it has been attached and emailed successfully.

  3. #3
    Join Date
    Feb 2012
    And would I run these commands through SSMS?

    Maybe it would be best for me to delete the file on the next run of the stored procedure as I am getting confirmation it was attached with the "Mail Queued" message displayed (no real confirmation)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts