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

2012年3月8日星期四

bcp failed when special characters {;" were used in the password from command line in Win 2

bcp worked with password in normal characters, but failed with {;"

I tried for SQL 2005 and SQL 2000, from Window 2003 SP1. Is this a bug?

When the special character { was used in the password, bcp failed with Native error 0.

>>

F:\ftp\log\Cases>bcp "sem5.sem5.server_system_log_1" in server_system_log_1.dat
-n -Smodonald -Usem5 -P{
SQLState = 08001, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Neither DSN nor SERVER keyword supplied
SQLState = 01S00, NativeError = 0
Warning = [Microsoft][ODBC SQL Server Driver]Invalid connection string attribute
>>

When the special character ; or " was used in the password, bcp failed with Native error 18456.

>>

F:\ftp\log\Cases>bcp "sem5.sem5.server_system_log_1" in server_system_log_1.dat
-n -Smodonald -Usem5 -P;
SQLState = 28000, NativeError = 18456
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'sem5'.

F:\ftp\log\Cases>bcp "sem5.sem5.server_system_log_1" in server_system_log_1.dat
-n -Smodonald -Usem5 -P"
SQLState = 28000, NativeError = 18456
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'sem5'.
>>

Could you try :

bcp "sem5.sem5.server_system_log_1" in server_system_log_1.dat
-n -Smodonald -Usem5 -P"{"|||

I tried the followings but it didn't work.

bcp "sem5.sem5.server_system_log_1" in server_system_log_1.dat
-n -Smodonald -Usem5 -P"{"

bcp "sem5.sem5.server_system_log_1" in server_system_log_1.dat
-n -Smodonald -Usem5 -P'{'

bcp "sem5.sem5.server_system_log_1" in server_system_log_1.dat
-n -Smodonald -Usem5 -P\{


|||Please try {{} for pwd {|||

I opened a case and got an answer.

Based on the Microsoft SQL Server 2005 online help for “Strong Passwords[SQL Server]”,

>>

if used in an OLE DB or ODBC connection string, a login or password must not contain the following characters: [] {}() , ; ? * ! @.. These characters are used to either initialize the connection or separate connection values.

>>

As the result, SQL Server Enterprise Manager allows all special characters but the OLE DB or ODBC connection is different.

|||

Thanks for following up your own post. It helps others when you share your solution.

2012年2月25日星期六

bcp command

Hi all,

I am trying to run a .bat file with this bcp command.

BCP "database.dbo.state" OUT "C:\TEMP\state.dat" -SServerName -U"userid" -P"password" -m1 -n -a65536 -E -q

However, it is not producing me a file as I expected.

Is there any other configuration I need to set before it work?

Any help would appreciated.What error messages are being produced? I don't think I've seen BCP fail silently in years. Have you ever done a successful BCP against that SQL Server from the same client maching?

-PatP|||The error is: "Error in attempting to load a pair of translation tables."|||The error is: "Error in attempting to load a pair of translation tables."

Excuse me?

Is it not creating a file, or not creating a file as "expected'

Because if it's the latter and you expect to "see" data, you won't. It's in native format.

You need to lose the -n and use -c|||The error is: "Error in attempting to load a pair of translation tables."That is definitely not an error message generated by BCP. What other programs are you running that might have generated that message?

-PatP