Search code examples
sql-serversqlcmdlocaldb

Executing .SQL file from cmd


i want to execute a .sql file from cmd. Here's my command :


sqlcmd -e -S "(localdb)\myDB" -i "C:\PathToMyFile\File.sql" -U user -P password


Here's my errors :


Errors


Microsoft ODBC Driver 13.1 is installed. Someone knows what I've done wrong? Thx.


Solution

  • You are using the wrong server name:

    sqlcmd -e -S "(localdb)\mssqllocaldb" -d MyDB -i "C:\PathToMyFile\File.sql" -U user -P password
    

    or with Integrated Authentication:

    sqlcmd -e -S "(localdb)\mssqllocaldb" -d MyDB -i "C:\PathToMyFile\File.sql" -E