Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2004
    Posts
    21

    Unanswered: xp_cmdshell - problem creating txt file for working for remote computer

    I am having problem creating/copying "txt" file in a remote machine by using the "exec master..xp_cmdshell" command in query analyzer. For example, we are getting errors for the following command:

    exec master..xp_cmdshell 'copy d:\testing\authors.txt \\<MyServerName>\<myFolderName>\authors.txt'

    (but exec master..xp_cmdshell 'copy d:\testing\authors.txt d:\testing1\authors1.txt' is working without any problems)

    Any ideas?

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Does your system account have right to the destination box?

    Or

    Does your path have spaces in the path or filename?

    Or

    Is the destination box on the Netwrok

    Or

    Is the destination box plugged in 8-)

    Or.....

    Whats the output from the statement....
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Jan 2004
    Posts
    21
    > Does your system account have right to the destination box?
    Yes
    > Does your path have spaces in the path or filename?
    No
    >Is the destination box on the Netwrok
    Yes
    >Is the destination box plugged in 8-)
    >Whats the output from the statement.... [/SIZE][/QUOTE]
    SQLState = S1000, NativeError = 0
    Error = [Microsoft][ODBC SQL Server Driver]Unable to open BCP host data-file
    NULL

    Any ideas? Thanks!

    Originally posted by Brett Kaiser
    Does your system account have right to the destination box?

    Or

    Does your path have spaces in the path or filename?

    Or

    Is the destination box on the Netwrok

    Or

    Is the destination box plugged in 8-)

    Or.....

    Whats the output from the statement....

  4. #4
    Join Date
    Jan 2004
    Posts
    21
    Also, my command is actually:

    exec master..xp_cmdshell 'bcp "SELECT * FROM pubs..authors" queryout \\NY1_AA\testing\authors.txt -U sa -P -c'

    For the copy command:
    exec master..xp_cmdshell 'copy C:\authors.txt \\NY1_AA\testing\results.txt'

    The output is actually:
    Access is denied.
    0 file(s) copied.

  5. #5
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Brett meant your SQL Server Service account. It should have the right to create files on the destination. Based on the error you posted it appears that it doesn't.

  6. #6
    Join Date
    Jan 2004
    Posts
    21
    Thanks Brett and rdjabarov.
    Can you tell me how I can check if my SQL Server Service account have right to create files on the destination? And tell me more about the SQL Service account? Thanks in advance.

    Originally posted by rdjabarov
    Brett meant your SQL Server Service account. It should have the right to create files on the destination. Based on the error you posted it appears that it doesn't.

  7. #7
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Originally posted by rdjabarov
    Brett meant your SQL Server Service account. It should have the right to create files on the destination. Based on the error you posted it appears that it doesn't.
    [dooooh]

    Of course

    [/dooooh]

    It's part of Windows security...do you have a network admin to work with?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  8. #8
    Join Date
    Jan 2004
    Posts
    21
    Thanks. Got the problem resolved. It was the startup service login problem.

Posting Permissions

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