Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was advised to make another question, from here -

My sqlcmd.exe is invoked with a command of the form -

sqlcmd -S .\MYSQLSERVER2008 -U MyUsername -P MyPassword 
-i C:\Database\hugescript.sql > log.txt 2> error.txt


log.txt says - Canceling connection. Please wait...
Error.txt says - Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : 
Operation was canceled..

How do I find out the cause of the problem and fix it ?

share|improve this question
up vote 1 down vote accepted

Lets try and test connectivity to your server with sqlcmd

-- connect to instance with sqlcmd
sqlcmd -S MYSQLSERVER2008 -U MyUsername -P MyPassword

-- attempt to open master

You should see the text : Changed database context to 'master'

Next type "quit" and then try this

Create a file called c:\test_sqlcmd.sql

Add the following code:

:setvar myserver "MYSQLSERVER2008"

:CONNECT $(myserver)

Now execute that script sqlcmd -i c:\test_sqlcmd.sql

You should see

Changed database context to 'master' and MYSQLSERVER2008

Once we have that out of the way, we can continue our research

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.