troubleshooting Question

How to run scripts with SQLCMD?

Avatar of brettr
brettr asked on
Microsoft SQL Server 2005
5 Comments1 Solution3763 ViewsLast Modified:
In MSSQL 2005, I'd like to update sprocs on the production server with sql files I have on the developer machine.  In SQLCMD, I'm trying to connect with the remote server but get the following error:

E:\Dev\Database\>sqlcmd -u myusername -p mypassword
Sqlcmd: 'myusername': Unexpected argument. Enter '-?' for help.

What should this syntax look like?

Once that gets going, what does the syntax for running a script look like?  Is this correct?

-i c:\Dev\Database\sproc1_update.sql -o c:\Dev\Database\sproc1_update.Log.txt

Once I connect, can I than just run lines like the one above or do I need to put a connect statement with each line?

Is there a more secure way to connect than sending the user name and password through plain text?  All I need is some way to run the developer scripts on production to synch the two.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros