0

I am trying to automate a report that is generated from the database on Azure database server. I am using below script in the batch file but I get the error.

Script:

osql -U [email protected] -S aazdb01.c224.database.windows.net -P "Password" -s "|" -i "c:\Users\fl1\Desktop\script.sql" -o "c:\Users\fl1\Desktop\output.txt"

Error:

Cannot open server "company.edu" requested by the login. The login failed.


If I run the below script with 'Sqlcmd', I still get the error.

Script:

sqlcmd -S aazdb01.c224.database.windows.net -U [email protected] -P "Password" -s "|" -i "c:\Users\fl1\Desktop\script.sql" -o "c:\Users\fl1\Desktop\output.txt"

Error:

Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Cannot open server "company.edu" requested by the login. The login failed..

Can anyone advise what is the issue here?

4
  • 1
    If you are trying to use an Azure Active Directory username and password add the -G switch. Read the requirement for using this switch in the help for sqlcmd here: learn.microsoft.com/en-us/sql/tools/… Both sqlcmd and the ODBC driver have to be fairly up to date.
    – Brian
    Commented Feb 10, 2021 at 21:21
  • Brian, thank you for sharing that link. So I did use -G but I get the error message Error: Sqlcmd: 'G': Unknown Option. Enter '-?' for help. Script: sqlcmd -S aazdb01.c224.database.windows.net -U [email protected] -P Password -G -s "|" -i "c:\Users\fl1\Desktop\script.sql" -o "c:\Users\fl1\Desktop\output.txt"
    – rk02
    Commented Feb 11, 2021 at 15:18
  • As I said: Both sqlcmd and the ODBC driver have to be fairly up to date.
    – Brian
    Commented Feb 11, 2021 at 15:25
  • Thanks Brian. So I do have 1. Microsoft Command Line Utilities 11 for SQL Server 2. Microsoft Command Line Utilities 15 for SQL Server 3. Microsoft ODBC Driver 11 for SQL Server 4. Microsoft ODBC Driver 17 for SQL Server
    – rk02
    Commented Feb 11, 2021 at 17:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.