Search code examples
sql-serversqlcmdazure-synapse

SQL Server login issue with sqlcmd


I am trying to run a file in Ubuntu using the sqlcmd command as shown below. We have a complex password set as per standards. Using that I am getting an error saying that "Login failed for the user "username" ".

sqlcmd -S ${servername} -d ${dbname}  -U ${sqlusername}  -P ${sqlpassword} 
       -I -i ${inputfile} -s"|" -r1 1>${logfile} 2>${errorfile}

I tried to execute the same by providing values with password in single quotes. It worked fine

As we cannot hard code the password. I tried the things shown here, but those didn't work.

sqlcmd -S ${servername} -d ${dbname} -U ${sqlusername} -P '${sqlpassword}'
sqlcmd -S ${servername} -d ${dbname} -U ${sqlusername} -P "${sqlpassword}"
sqlcmd -S ${servername} -d ${dbname} -U ${sqlusername} -P \'${sqlpassword}\'

Can someone please help me - am I doing something wrong?


Solution

  • Thank for @Larnu's comment.

    The error caused by your password has has dollar sign in it.