I need to alter a database using a batch file, for a simple example, drop a table. I´m using local SQL Express (SQL Server 2008 R2) with user sa
and its password.
How would the bat file be?
How can I specify in the script the password and that I use in SQL Express?
Feedback Guys, first create database example live; before execute sql file below.
If you use Integrated Security, you might want to know that you simply need to use
-E
like this:Take a look at the
sqlcmd
utility. It allows you to execute SQL from the command line.http://msdn.microsoft.com/en-us/library/ms162773.aspx
It's all in there in the documentation, but the syntax should look something like this:
You can do like this
From your command prompt run
sqlcmd /?
to get all the options you can use withsqlcmd
utility