Solved

Error running SQL script from BAT file

Posted on 2009-05-12
1
272 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 500 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
batch script 3 49
Batch File- Finding Drive Description 11 43
Editing a .bat file to point to a different directory 5 42
Change this SQL to get all nodes 3 40
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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