显示标签为“authors”的博文。显示所有博文
显示标签为“authors”的博文。显示所有博文

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

2012年3月20日星期二

bcp problem

Can any one why I am facing the following error..
bcp pubs..authors out 'c:\Testing.xls' -c -S{local} -Usa -PDbPass
[Microsoft][ODBC SQL Server Driver]Syntax error or access violation
Thanks
bcp pubs..authors out 'c:\Testing.xls' -c -Usa -PDbPass
Without the -S, it will try the default instance on the local host. It is
generally best to give a server name and instance to ensure you don't
connect to the wrong server.
Regards
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Rogers" <naissani@.hotmail.com> wrote in message
news:u4Xd4U%234FHA.2616@.TK2MSFTNGP12.phx.gbl...
> Can any one why I am facing the following error..
> bcp pubs..authors out 'c:\Testing.xls' -c -S{local} -Usa -PDbPass
> [Microsoft][ODBC SQL Server Driver]Syntax error or access violation
> Thanks
>
|||I used the following query but it gave me an error..
bcp pubs..authors out 'c:\Testing.xls' -c -Usa -PDbPass
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '.'.
Thanks
"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
news:etsm8z%234FHA.2040@.TK2MSFTNGP14.phx.gbl...
> bcp pubs..authors out 'c:\Testing.xls' -c -Usa -PDbPass
> Without the -S, it will try the default instance on the local host. It is
> generally best to give a server name and instance to ensure you don't
> connect to the wrong server.
> Regards
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "Rogers" <naissani@.hotmail.com> wrote in message
> news:u4Xd4U%234FHA.2616@.TK2MSFTNGP12.phx.gbl...
>