Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to I execute a script without Management Studio?

Status
Not open for further replies.

Amesville

Programmer
Oct 10, 2011
93
US
Hi Folks

I've installed SQL Server 2005 Express on a test machine, and I have a script to create a database that I want to run against it to, well, create the database. I used Management Studio to create the script on my development machine, but I don't have it (and don't want it) on the test machine. How can I execute the script to create the DB without management studio?
 
you can use SQLCMD commands. Those commands are run from a command window. Here's an example:

sqlcmd -i C:\MyFolder\MyScript.sql -o C:\MyFolder\MyOutput.txt

Look up sqlcmd utility in the Books OnLine for SQL Server and you'll see the different commands and syntax.

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
If you don't have SQLCMD on the computer, you can download it from here:


Scroll down to Microsoft SQL Server 2008 Command Line Utilities



-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
I should also mention that the link I pointed you to is for SQL 2008, but the command line utility (SQLCMD) will work against a SQL2005 database.


-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
If you are working on a deploy process then the command line should get you there, otherwise you can just connect to your test machine and run the script from your main box.
Just putting that out there...

Lodlaiden

You've got questions and source code. We want both!
Here at tek tips, we provide a hand up, not a hand out.
 
Thanks Guys - I tried that and got an error that SQL Server 2005 Express doesn't allow remore connections. I eventually gave up and downloaded 2005 Management Studio to do the install (and that worked) but I know I'm going to run into this again...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top