Search code examples
azure-sql-databasebcp

bcp utility complains about "Neither DSN nor SERVER keyword supplied"


I'm trying to import a file with bcp.exe into Azure SQL. I am supplying the server name with the -S argument, and it's formatted to what I believe to be correct. Yet it complains about not having a SERVER keyword. Bcp doesn't have a SERVER keyword but uses the -S argument instead. The error message comes from the ODBC driver that bcp uses. I'm 90% certain this has worked in the past.

I've tried running this from both PowerShell and cmd.exe:

bcp myschema.tb_mytable in "C:\Users\myname\AppData\Local\Temp\bcp_tmp_file_e1de3d69-b637-4b0e-aa67-e26a44394b4f" -c -r "\r\n" -S "tcp:thesqlserver.database.windows.net,1433" -d THEDATABASENAME -b 50000 -U THE-USER-NAME -P "the@-?^&secret{password;^&]"

Error message:

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
(base) PS C:\Users\myname>

Bcp version is latest:

C:\Users\myname>bcp /v
BCP - Bulk Copy Program for Microsoft SQL Server.
Copyright (C) Microsoft Corporation. All Rights Reserved.
Version: 15.0.2000.5

Possibly unrelated but I've escaped characters in the password with the ^-character according to the bcp documentation.


Solution

  • It seems that the combination of "{", and ";" is causing the BCP or ODBC driver to go awry (not sure which one)....I can replicate the problem also with this string: {abc;.

    Can you just trying changing the password. It looks like that different escaping rules for DOS prompt or Powershell, BCP and ODBC are somehow conflicting here.