?
Solved

Error running SQL script from BAT file

Posted on 2009-05-12
1
Medium Priority
?
276 Views
Last Modified: 2012-05-06
We are running SQL server express 2005 on a Virtual server.  In order to backup our databases nightly, I have a Windows scheduled tasks that runs a BAT file every night with the following code: sqlcmd -S . -i "C:\SQLbackup\DatabaseBackup.sql"
The SQL file referenced has code to run the backup.

We recently moved our server from one machine to ther other - it had previously worked and now it doesn't which means the code is okay, but there is a setting on the new machine that needs to be fixed.  When I run the BAT file, I get the following error:

C:>sqlcmd -S . -i "C:\SQLbackup\DatabaseBackup.sql"
HResult 0x2, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [2].
Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not  allow remote connections..
Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.

I've already configured the protocols in SQL Server Configuration Manager - shared memory, named pipes, and TCP/IP are enabled.  In MSSMSE, remote connections are also enabled. (600 second query timeout)
In SQL server surface area configuration, I have local & remote connections set to be allowed using both TCP/IP and named pipes.

Any ideas what this could be??

Thanks!!
M
0
Comment
Question by:cherrylane
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 13

Accepted Solution

by:
Wizilling earned 2000 total points
ID: 24370302
is it possible the user doesnt have access to the box. try using a sa account

also try these:

sqlcmd -S localhost -i etc.....

or sqlcmd -S ServerName -i etc...
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question