sql-serverbcp

Escape { in the bcp -P switch


Exporting query data to a file from bcp utility from cmd. Password has { symbol which is giving error as follows:

SQLState = 08001, NativeError = 0 Error = [Microsoft][ODBC Driver 17 for SQL Server]Neither DSN nor SERVER keyword supplied SQLState = 01S00, NativeError = 0 Warning = [Microsoft][ODBC Driver 17 for SQL Server]Invalid connection string attribute

Please let me know how can I escape this symbol in the password. BTW, Can't change the password.

I've tried enclosing double quotes and single quotes and ^ before {. But didn't helped.

Let me know how can I escape this symbol


Solution

  • It worked with password enclosed with flower braces like as follows.

    bcp "Database.dbo.Table" out "outputfile.txt" -w -S Server -U Username -P {{Ndar)at}
    

    Enclosed with double quotes and doubling the braes as follows didn't worked.

    "{{Ndar)at"