0

In bash, I am using the following bcp command to create an XML format:

bcp DATABASE.[UserData] format nul -c -x -f F:\UsageExports\UserData.xml -t, -T

However, when I run the same command in Powershell, I get the error: Missing argument in parameter list

I also tried executing the command without in Powershell:

bcp DATABASE.[UserData] format nul -c -x -f F:\UsageExports\UserData.xml -t -T

However, the -t tag does not work and the terminator is not included in the XML.

1 Answer 1

3

PowerShell can be rather picky when it comes to passing arguments to an external command. Usually the best way of dealing with such a situation is to define an array with the arguments and then splat that array on the command:

$params = 'DATABASE.[UserData]', 'format', 'nul', '-c', '-x',
          '-f', 'F:\UsageExports\UserData.xml', '-t,', '-T'

& bcp @params

In your case the issue is probably caused by the argument , for the parameter -t. A comma in PowerShell is used for constructing arrays. I would guess that -t, -T is interpreted as @('-t', '-T') and then mangled to '-t -T' when the external command is invoked.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.