0

I´m trying to execute the bcp utility through SQLCMD:

bcp XXXX.dbo.pru in 'c:\users\AAAA\desktop\p..xls' /S localhost\SqlExpress

but when I execute it, I get this error:

:"incorrect syntax near the '.' keyword"

If i try to put only the name of the table without the database name and scheme says :

"incorrect syntax near the 'in' keyword"

I was on the MSDN page of bcp and dont see what is wrong, can anyone help me?

Thanks.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ion
  • 549
  • 1
  • 11
  • 25
  • `bcp` is a separate executable that you run. It isn't a command sent to the server. – Martin Smith Jun 30 '15 at 13:10
  • i know that, but i need to launch the executable from somewhere, in this case from SQLCMD, am i doing wrong? – Ion Jun 30 '15 at 13:48
  • Ok, i think what you say and i proble launching from the cmd, and this time dont give me these error. The bcp asked me about the tipe of data of the columns i put always that he sugest me and then they say a few times (one for column) something like "string data wil be truncated from the right" (i have all in spanish, so the thats a translation of the error) and finallly says "unexpected EOF was find in a bcp data type file" (Again not literally, is a translation from the spanish) and "0 rows copied" – Ion Jun 30 '15 at 14:22
  • https://stackoverflow.com/questions/52295174/unexpected-eof-encountered-in-bcp-data-file/52295180#52295180 – jophab Sep 12 '18 at 12:50

1 Answers1

0

Should your ending server/instance be hyphen 'S' (-S) instead of slash 'S' (/S)?

Secondly, you might need to use double quotes " instead of single quotes ' around your filename.

Edward Comeau
  • 3,874
  • 2
  • 21
  • 24
  • you are right, i write wrong here, but in the sqlcmd i put it with the -S. Anyway i probe all the ways, put the -S localhost\SqlExpress, i probe to put only: 'code' bcp XXXX.dbo.pru in "c:\users\AAAA\desktop\p..xls" and always give me a similar error, sametimes says that the error is in the '.' sametimes the error is in the 'in'. And addition i prove not puting the doublé quotes – Ion Jun 30 '15 at 13:45
  • The main problem was that i was trying to do from the sqlcmd, now i launch directly from the cmd and now launch correctly, but give me an error saying that an a unexpected EOF was encountered. Any idea about who can be the problema?. When launch bcp they ask me about the format(varchar, int,datetime, ...) and the size, perhaps the problema is there? and i read about a format file for the bcp, you know where can i read more about it? – Ion Jun 30 '15 at 14:32
  • This post may help you - http://stackoverflow.com/questions/26339092/unexpected-eof-encountered-in-bcp – Edward Comeau Jun 30 '15 at 16:08