Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2003
    Posts
    24

    Unanswered: Executing BCP utility inside sp....

    Hi ,

    My reuierement is to execute a bcp to write the query output to a flat file. I am using the following syntax...

    exec xp_cmdshell 'bcp "SELECT top 50 * tbl_xyz" queryout tbl_xyz_output.txt -c -S abc -U x -P x'

    But I am getting the following error....

    output
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    CTLIB Message: - L6/O8/S5/N3/5/0:
    ct_connect(): directory service layer: internal directory control layer error: Requested server name not found.
    Establishing connection failed.
    NULL


    This bcp executes perfect if I am going to call from command prmomt.

    Can anyone please help me in this....

    Thanks in Advance.

    -Mohit.

  2. #2
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393

    Re: Executing BCP utility inside sp....

    I can help you here
    just a second...

  3. #3
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393

    Re: Executing BCP utility inside sp....

    exec master..xp_cmdshell 'bcp "SELECT top 10 * from M158005..T74pers" queryout tbl_xyz_output.txt -c -S (LOCAL)\MERCURE -U sa -P '


    I've exected this on my computer and it works

    maybe :
    - you need a FROM in your query
    - you have to prefix tbl_xyz by the name of your database
    DB..tbl_xyz
    - you have to add the instance name to the server name

  4. #4
    Join Date
    Dec 2003
    Posts
    24
    Thanks a lot Karolyn .... It worked for me also....

  5. #5
    Join Date
    Dec 2003
    Posts
    24
    Thanks a lot Karolyn... It worked for me also.....

Posting Permissions

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