Solved

Error running SQL script from BAT file

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
In this article I will describe the Copy Database Wizard 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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now