5

i try to access with sqlcmd by this command:

sqlcmd -U sa -P $test$ -S hostname -d db_test -i .\prova.sql > upgrade.log

but the login failed.

The password i correct, i think is a problem with special character, in this case the $.

Do yuo have any solutions?

Thanks F.

fabrix_00
  • 153
  • 4
  • 5
  • 11
  • possible duplicate of [Escaping special symbols in Sqlcmd](http://stackoverflow.com/questions/17041145/escaping-special-symbols-in-sqlcmd) – bummi Oct 23 '14 at 08:14
  • Please provide the version of SQL Server you are connecting to via this command line. On 2014 it works: sqlcmd -U sa1 -P $password$ -S VMDBSRVDEMO001\SQLEXPRESS2014 -d itest -i .\prova.sql > upgrade.log – Ispirer SQLWays Migrations Oct 23 '14 at 08:27
  • i use sql 2005,2008 and 2012, not 2014. – fabrix_00 Oct 23 '14 at 08:39

2 Answers2

2

the solution is use the "", in this case:

-P "$test"

fabrix_00
  • 153
  • 4
  • 5
  • 11
  • 4
    This solution did not work for me. Also your password seems to be missing the second $ in this example. – Hack-R Mar 29 '18 at 20:34
-1

Pop a -x at the start of your sqlCMD and them for the password use double quote marks after the P.

EG -

sqlcmd -x -U sa -P "$test$" -S hostname -d db_test -i .\prova.sql > upgrade.log