2

I have tried many things, but I'm still not getting this to work. Here's the code:

bcp RFID.dbo.ResultsDump format nul -t, -c -x -f C:\RFID.xml -S"ALBERTLAST-PC\SQLEXPRESS" -UAlbert Last -P -T

All I want to do is create an XML format file from ResultsDump table, and the above statement doesn't even work. My username is "Albert Last" where Last is my last name, yet this is what the above statement returns:

bcp:  unknown option A
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
  [-m maxerrors]            [-f formatfile]          [-e errfile]
  [-F firstrow]             [-L lastrow]             [-b batchsize]
  [-n native type]          [-c character type]      [-w wide character type]
  [-N keep non-text native] [-V file format version] [-q quoted identifier]
  [-C code page specifier]  [-t field terminator]    [-r row terminator]
  [-i inputfile]            [-o outfile]             [-a packetsize]
  [-S server name]          [-U username]            [-P password]
  [-T trusted connection]   [-v version]             [-R regional enable]
  [-k keep null values]     [-E keep identity values]
  [-h "load hints"]         [-x generate xml format file]
NULL

It's thinking that I am asking for option A, because when I put square brackets around Albert Last, here's what I get:

bcp:  unknown option [

I've also tried this WITHOUT specifying server name, username, or password, with just -T. This is what I get:

SQLState = 37000, NativeError = 4060
Error = [Microsoft][SQL Native Client][SQL Server]Cannot open database "RFID" requested by the login. The login failed.
SQLState = 28000, NativeError = 18456
Error = [Microsoft][SQL Native Client][SQL Server]Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
NULL

I've looked everywhere online and have not seen a similar problem before, and I'm beginning to think that this is just a simple mistake that I'm not catching.

Can somebody help?? Or if there is a way to generate format xml file RFID.xml from table ResultsDump without bcp, that would be greatly appreciated! Thanks in advance!

1
  • If it helps, I was originally using bronios.com/index.php/2007/03/29/… but I can't even run the first statement to create the XML format file. Commented Aug 23, 2010 at 9:46

1 Answer 1

1

Can you try if the following works:

-U"Albert Last"

I can vaguely remember that I have done it this way a long time ago.

The error you see in your comment has something to do with your format file (c:\RFID.xml), not with your username. Possibly you do not have write access to c:\? Can you try it with a relative path, just RFID.xml? And make sure you then run the bcp command from a location where you have write access.

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

3 Comments

Tried that before, but now it doesn't think I specified the correct username: SQLState = S1000, NativeError = 0 Error = [Microsoft][SQL Native Client]Format file could not be opened. Invalid name specified or access denied. NULL Unless I'm interpreting the output incorrectly?
Doesnt -T already give me access? In either case, I tried RFID.xml instead of c:\RFID.xml and I get the same error (Invalid name specified or access denied). How do I know if I have write access to the folder I am running the SQL statements out of? Sorry about all the questions, and thanks for your patience.
You should either specify -T or -U and -P, not both. -T tells bcp that you are using a trusted connection. This means nothing more than that it will connect to SQL Server using the credentials of the user running bcp. From what folder are you running bcp?

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.