0

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.