'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
Solution 1:[1]
There are can be three reasons:
- SQL Server (or mixed) authentication is disabled
- The password used in the command is wrong
- 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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |