Freetds could not connect to SQL Azure by server name (-S), but connect by host (-H) works

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.

Upvotes: 6

Views: 1281

Answers (2)

meet-bhagdev
meet-bhagdev

Reputation: 2708

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.

Upvotes: 1

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).

Upvotes: 11

Related Questions