Take the 2-minute tour ×
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. It's 100% free, no registration required.

I was advised to make another question, from here - http://stackoverflow.com/questions/19674045/need-help-to-make-sqlcmd-run-as-per-requirements

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

Now,

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

1 Answer 1

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
USE MASTER;
GO

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)
USE MASTER;
GO
SELECT @@SERVERNAME;
GO

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

 
discard

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.