5

I have installed freetds and it looks working fine, when I try to connect by host:

tsql -H myhost -U myuser -P mypass -p 1433
locale is "C/UTF-8/C/C/C/C"
locale charset is "UTF-8"
using default charset "UTF-8"
1> 

I have configured freetds.conf:

[azure]
        host = myhost
        port = 1433
        tds version = 7.0

But when I'm trying to connect by server name (azure) it fails:

tsql -S azure -U myuser -P mypass
locale is "C/UTF-8/C/C/C/C"
locale charset is "UTF-8"
using default charset "UTF-8"
Msg 40532 (severity 20, state 1) from azure:
    "Cannot open server "azure" requested by the login.  The login failed."
Error 20002 (severity 9):
    Adaptive Server connection failed

Tried on macos and debian.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

2 Answers2

11

The answer was simple, but strange. When you connect by config file (-S) you should use username@host as login, not just username. It's strange, but when you connect by host (-H), you could use only username (but could use username@host too).

1

Glad it worked out for you. Check out this doc - http://www.freetds.org/userguide/odbcconnattr.htm

As general practice, we recommend that you use -S

Let me know if you have further questions.

meet-bhagdev
  • 2,608
  • 18
  • 22