EXEC master..xp_cmdshell wont send to URL

  • Any ideas?

    #1 works, #2 dont. Just to make sure it was not a rights issue, I added everyone to the folder for #2 but no luck.

    1. EXEC master..xp_cmdshell'bcp "SELECT * FROM [MT].[dbo].[alr]" queryout "D:\TEST\mrns.txt" -c -T'

    2.EXEC master..xp_cmdshell'bcp "SELECT * FROM [MT].[dbo].[alr]" queryout "\\01-abc-01c\D$\TEST\mrns.txt" -c -T'

    SQLState = S1000, NativeError = 0

    Error = [Microsoft][SQL Server Native Client 11.0]Unable to open BCP host data-file

    Thanks

  • 456789psw (5/5/2015)


    Any ideas?

    #1 works, #2 dont. Just to make sure it was not a rights issue, I added everyone to the folder for #2 but no luck.

    1. EXEC master..xp_cmdshell'bcp "SELECT * FROM [MT].[dbo].[alr]" queryout "D:\TEST\mrns.txt" -c -T'

    2.EXEC master..xp_cmdshell'bcp "SELECT * FROM [MT].[dbo].[alr]" queryout "\\01-abc-01c\D$\TEST\mrns.txt" -c -T'

    SQLState = S1000, NativeError = 0

    Error = [Microsoft][SQL Server Native Client 11.0]Unable to open BCP host data-file

    Thanks

    Yes... SQL Server doesn't have privs to the D: of the 01-abc-01c system. You'll need to create a share on that box and give the SQL Server login privs to see it.... even if it's the same box, IIRC.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Thanks for the help Jeff, Thats what I thought as well.

    I should have explained better, the Problem is the D: & 01-abc-01c share are the same location.

    The goal is to get it to write a URL adderes that belongs to a different server

    I orginaly could not get it to write to the D drive untill I added EVERYONE.

  • I'd be real careful about having a share on my SQL SERVER that has been given privs to EVERYONE. In fact, I don't generally allow any shares on my SQL Servers. I always make someone build a file server that my SQL Server can link to. That way, I don't have to worry about things like the "D:" drive. Everyone has to use a UNC to get to the files including SQL Server.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I agree with Jeff here. A share on your SQL Server that EVERYONE can write to just sounds like a recipe for disaster. Putting security concerns aside for a moment, you don't have it on the same drive as your data or log files, do you? If EVERYONE can write files to the same drive, you can end up with drive space problems quickly. You might have a surprise when you need to grow your database.

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

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