BCP Failure

  • I am using bcp to create a text file. It was working fine but stopped working. Here is the bcp command.

    exec master..xp_cmdshell 'bcp ''select clientmatter from mytemp order by acctid'' queryout e:\sql_backup\test.txt -c, -T'

    The text file is not being created. When I manually place the file in the target directory, the email will not work with the @file_attachments='e:\sql_backup\test.txt'. This is the error msg.

    Executed as user: NT AUTHORITY\NETWORK SERVICE. Attachment file e:\sql_backup\test.txt is invalid. [SQLSTATE 42000] (Error 22051). The step failed.

    When I remove the @file_attachments='e:\sql_backup\test.txt', the email will work.

    Thanks in advance. Mike

  • most likely permissions,

    if you right click on that specific folder, and go to the security tab, you can see everyone who has permissions.

    * Note that NT Authority\Network Service DOES NOT have permissions)

    personal folders like \Users\username\Desktop are the same situation.

    you'll want to either change the login used to run the service, or change the destination for the file to a fodler NT Authority\Network Service DOES have access to.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • That worked!

    Thanks Lowell

  • Lowell,

    Partial success. The file attachment is working but my bcp command now appears to be the problem. The bcp command does not build a new text file:

    exec master..xp_cmdshell 'bcp ''select clientmatter from adr_live.dbo.mytemp order by acctid'' queryout e:\sql_backup\test.txt -T -c'

    Any Ideas?

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

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