Reputation: 3492
I am trying to execute the .sql file from batch script, but not able to execute. Script has multiple scripts such as Create Table , Stored Procedure separated by GO statement.
I tried with the below script, however script was not executed.
DB Servername : localhost\SQL2017
Authentication : Windows
sqlcmd -E -S localhost\SQL2017\MyDatabase -i C:\SQLScripts\TestScript.sql
Upvotes: 0
Views: 113
Reputation: 5684
Try this instead:
sqlcmd -E -S localhost\SQL2017 -d MyDatabase -i C:\SQLScripts\TestScript.sql
You need to use the -d
parameter to specify the database name. The -S
parameter should contain only the server name and the instance.
Upvotes: 1