I am completely new to the BCP utility and fairly new to SQL Server
I am learning from a book and I am trying the following example (the server
I'm learning on is called contractor and a password has not been give to the
sa)
bcp pubs..authors out authors.txt -C -r \n -t, -U sa -P -S contractor
When I run this in Query Analyser i get the error message..
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '.'.
I have tried puuting quotes around the database and the table name as
follows-
bcp "pubs..authors" out authors.txt -C -r \n -t, -U sa -P -S contractor
and get the error
Server: Msg 179, Level 15, State 1, Line 1
Cannot use the OUTPUT option when passing a constant to a stored procedure.
Please can anybody help me to get this first bit working?
Thanks in anticipation.In your bcp statement, is the -C supposed to indicate that it is a
character file? If so, it needs to be lowercase (-c), otherwise it
indicates the code page, which expects a value. Also, I don't know if
this makes a difference, but I've never used spaces between the options
and the values (for example, -Usa instead of -U sa). I thought I
remembered both working, but in the help I didn't see anything about
the space being allowed and the samples given do not have spaces.
HTH,
-Tom.|||Stevie D (Steve@.127.0.0.1) writes:
> I am completely new to the BCP utility and fairly new to SQL Server
> I am learning from a book and I am trying the following example (the
> server I'm learning on is called contractor and a password has not been
> give to the sa)
> bcp pubs..authors out authors.txt -C -r \n -t, -U sa -P -S contractor
> When I run this in Query Analyser i get the error message..
You don't BCP from Query Analyzer. You run it from a command-line
window.
And, as Thomas pointed out, you should use -c and not -C. The
spacing should be OK, though.
> Server: Msg 170, Level 15, State 1, Line 1
> Line 1: Incorrect syntax near '.'.
(The reason you get this syntax error is that bcp is not an SQL
command. Everything that is an identifier, but not a command is
taken as a stored procedure command. Next token is pubs. When calling
stored procedures quotes around strings that follow identifier syntax
are optional. (This is to permit us to write "sp_help tbl", instead
of "EXEC sp_help 'tbl'".) When the dot comes there is no longer
any saver.)
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp
没有评论:
发表评论