简体   繁体   中英

Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Login failed for user 'sa'

I am trying to execute one stored procedure using 'sa' user through perl script

save this line in a perl file and execute that perl file

system("start /wait sqlcmd.exe -S serverName -U sa -P test@123 -d JSONdb -Q \"EXECUTE UPDATE_SP\" -o C:\\Temp\\log.txt");

=============================================================================

-S serverName :: sql server which i want to connect.

-U sa -P test@123 :: login user credentials

-d JSONdb :: database name.

\\"EXECUTE update_JSONTable\\" :: command to execute stored procedure [update_JSONTable]

-o C:\\Temp\\log.txt" :: saving logs

There are can be three reasons:

  1. SQL Server (or mixed) authentication is disabled
  2. The password used in the command is wrong
  3. The database [JSONdb] is not available

Another reason can be related to special characters escaping. Your password contains @ , therefore this argument is to be also adjusted:

 -P test@123 =>  -P test\@123

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM