2012年2月18日星期六

bcp

Any ideas why this wont work?
bcp {Pic_Count_Import} in \\DATASRVR\InetPub\wwwroot\images\Pic_Count.txt -q -t "," -SDATA -U"aa" -P"blah"
Thanksdrop the squirrelly brackets around the table name and the quotation marks around the user name and password.

Generally, when I use bcp I explicitly state the table in the form <database name>.<owner name>.<table name>.

What error message or undesired results are you getting?|||I changed it to this
bcp dbo.Pic_Count_Import in \\DATASVR\InetPub\wwwroot\images\Pic_Count.txt -q -t "," -SDATA -Uaa -Pblah

Still I get syntax error near '.'

Originally posted by Paul Young
drop the squirrelly brackets around the table name and the quotation marks around the user name and password.

Generally, when I use bcp I explicitly state the table in the form <database name>.<owner name>.<table name>.

What error message or undesired results are you getting?|||from books online, bcp utility, overview:

-q

Executes the SET QUOTED_IDENTIFIERS ON statement in the connection between the bcp utility and an instance of SQL Server. Use this option to specify a database, owner, table, or view name that contains a space or a quotation mark. Enclose the entire three-part table or view name in double quotation marks (" ").

I would suggest dropping the -q argument. Try it and let us know.|||Same

Originally posted by Paul Young
from books online, bcp utility, overview:

-q

Executes the SET QUOTED_IDENTIFIERS ON statement in the connection between the bcp utility and an instance of SQL Server. Use this option to specify a database, owner, table, or view name that contains a space or a quotation mark. Enclose the entire three-part table or view name in double quotation marks (" ").

I would suggest dropping the -q argument. Try it and let us know.|||what happens if you add the database name?|||Same..

Originally posted by Paul Young
what happens if you add the database name?|||Ya know what, this may be a stupid question.. can you use bcp ina stored procedure?

That is where I am doing this..

preceded with EXEC bcp....

or should I be using BULK INSERT ?

not sure what the differences are?|||bcp is a command line utility. You can run bcp within a stored procedure but you need to use xp_cmdshell. You should use the bulk insert tsql statement instead - also have you looked at using the bulk insert task in dts ?|||Also know that bcp can import/export while bulk insert can only copy a data file in sql server (one-way only)

没有评论:

发表评论