0

I need to import a database into a SQL Server instance using a batch script and the database is provided by an sql file.

How can I do This?

The SQL file was generated by the SQL Server management studio.

1 Answer 1

1

SQL Server has a command line utility called SQLCMD. It will let you do things like run scripts or restore a database backup. The -i parameter allows you to specify an input file.

There is also an article here that has a quick intro to SQLCMD.

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

2 Comments

Would it be something like this? sqlcmd -U mario -P mario -i file.sql
I believe so but you'll probably also need to specify the server (-S) and maybe a few other things depending on your situation. Type 'sqlcmd /?' on the command line to get a full list of the options. It may take a couple of tries to get it right so try it first on a development server if you can.

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.