2

I would like to use the sqlcmd cli on a mac to run a script on a Microsoft SQL Server using Windows Authentication.

Software details:
Mac OS 10.13
MSSQL 2012 version 11.0.2100.60
sqlcmd version 17.0.0001.1 Linux

As a test, I tried:
sqlcmd -S hostname,port\\database_name -U domain\\user.name -P "XXX" -q "select @@version"

But I received the error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed for user domain\user.name

I also configured a freetds DSN and attempted to connect using:
sqlcmd -S DSN_NAME -D -U domain\\user.name -P "XXX" -q "select @@version"

But I received the error:
The DSN specified an unsupported driver

For what it's worth, I'm able to use the same DSN through isql by doing: isql DSN user.name password

Any help greatly appreciated!

enmyj
  • 371
  • 4
  • 14

1 Answers1

1

A few things that might help. If you want to use Windows Authentication I think that you will have to set up Kerberos and NOT supply the login id and password with the sqlcmd command.

I had a confusing scenario where isql with freetds would connect using username and password when the DB server was set to only receive Windows Authentication connections, but the MS ODBC driver would not connect using the username and password. After connecting my computer to the network, settings up kerberos, and getting a kerberos ticket I was able to connect using:

sqlcmd -S 'ServerName'
Bryan Prazen
  • 323
  • 3
  • 7