Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2016
    Posts
    3

    Answered: exec xp_cmdshell bcp failing

    I have the following bcp (using AdventureWorks2008R2) and it keeps failing. What am I missing?

    EXEC xp_cmdshell 'bcp "SELECT Person.FirstName, Person.LastName, EmailAddress.EmailAddress FROM AdventureWorks2008R2.Person.Person join Person.EmailAddress on Person.BusinessEntityID = EmailAddress.BusinessEntityID" queryout C:\Datafiles\Datatest.txt -c -t -S WINSERVER2008 -T'

    Is there something else I should include after the "-S"

  2. Best Answer
    Posted by Pat Phelan

    "BCP would have worked if you had used the -d AdventureWorks2008R2 parameter.

    -PatP"


  3. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    That depends on the output of the xp_cmdshell execution and the content of the SQL Server error log.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  4. #3
    Join Date
    Apr 2016
    Posts
    3

    Answer found

    Answer provided by Pat Phelan
    Last edited by SalMinella; 04-29-16 at 23:18.

  5. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    BCP would have worked if you had used the -d AdventureWorks2008R2 parameter.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  6. #5
    Join Date
    Apr 2016
    Posts
    3
    Quote Originally Posted by Pat Phelan View Post
    That depends on the output of the xp_cmdshell execution and the content of the SQL Server error log.

    -PatP

    It appears Pat Phelan is correct. I just tried it as you suggested with the "-d AdventureWorks2008R2" and it ran like a charm.

Tags for this Thread

Posting Permissions

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