2

I was advised to make another question, from here - https://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 ?

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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