2012年3月22日星期四

bcp select querylist error

Hi,
Does BCP Select work in MS SQL Server 7.0, because when I run this
command :

bcp "SELECT au_fname, au_lname FROM pubs..authors ORDER BY au_lname"
queryout Authors.txt -c -SWIN2K -Usa

I always get this error :

output
--------------------
Copy direction must be either 'in', 'out' or 'format'.
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] [-6 6x file format] [-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"]

(12 row(s) affected)

MS SQL SERVER (7.00.623) is on WIN2000 SP4 Server

Thanks in advance
Nipon WongtrakulYou can create a view (with only the selected fields) and export the
result of the view using BCP. That will solve your problem.|||Nipon (niponw@.yahoo.com) writes:
> Hi,
> Does BCP Select work in MS SQL Server 7.0, because when I run this
> command :
> bcp "SELECT au_fname, au_lname FROM pubs..authors ORDER BY au_lname"
> queryout Authors.txt -c -SWIN2K -Usa

That command looks fine to me, except that you are missing the -P option
to specify a password. (Or use -T to specify trusted connection rather
than -Usa.)

From which context are you running this command? A command-line window?
SQL Agent? Or something else?

And just to be sure: above you have split the command on two lines, but
this is only because of the format for news articles. You have a single
line in real life, don't you?

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

没有评论:

发表评论