1

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.

jarlh
  • 42,561
  • 8
  • 45
  • 63
Emile
  • 592
  • 10
  • 36
  • can you go to sql server configuration manager and make sure SQL Server (MSSQLSERVER) is running? in addition: https://stackoverflow.com/questions/30953100/invoke-sqlcmd-a-network-related-or-instance-specific-error-occurred-while-esta – Eray Balkanli Feb 06 '18 at 19:57
  • It's never a good idea to post an image of your errors. You'll do much better here to put the error **text** here, even if you have to re-type it. – Joel Coehoorn Feb 06 '18 at 20:19
  • @JoelCoehoorn why it is not good idea? – Eray Balkanli Feb 06 '18 at 20:23
  • 1
    @ErayBalkanli Lot's of people will never see that image or choose not to bother with it. Using an image instead of text limits the number of people who might have helped you. – Joel Coehoorn Feb 06 '18 at 20:38
  • network issue . – MichaelEvanchik Feb 06 '18 at 20:41
  • 2
    It also won't come up in google searches, so the overall quality of StackOverflow as a resource is lower. – Greg Viers Feb 06 '18 at 21:05

1 Answers1

2

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
ErikEJ
  • 40,951
  • 5
  • 75
  • 115