Solved

MS SQL 2008 error when trying to execute script.

Posted on 2014-07-24
3
821 Views
Last Modified: 2014-07-25
I trying to automize a SQL Backup by executing a SQL script from my pc at work but i get an error:

The batch script to start the sql script:

echo off
sqlcmd -E -S SERVERDB\MSSQLSERVER -i C:\Users\MYNAME\Desktop\TestBackupSql.sql
SET /p delExit=Press the ENTER key to exit...:

/* HResult 0x57, Level 16, State 1
SQL Server Network Interfaces: Connection string is not valid [87].
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A network-related or in
stance-specific error has occurred while establishing a connection to SQL Server
. Server is not found or not accessible. Check if instance name is correct and i
f SQL Server is configured to allow remote connections. For more information see
 SQL Server Books Online..
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Login timeout expired.
Press the ENTER key to exit...: */

I can open a sql session to serverdb from an instance on my pc.I guess this means there might be someting wrong with my syntax or something i've omitted from script file?
0
Comment
Question by:The_Nibbler
[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
3 Comments
 
LVL 33

Accepted Solution

by:
ste5an earned 167 total points
ID: 40216322
You should test the connectivity in the first place:

sqlcmd -E -S <YourServerName> -q "SELECT @@VERSION;"

Open in new window


Onyl use the server name or IP. Don't use the default instance name. When also doesn't work, you need to check, whether or not your server accepts remote connections.

Here's an good tutorial with screenshots: How to enable remote connections in SQL Server 2008?
0
 
LVL 12

Assisted Solution

by:Tony303
Tony303 earned 166 total points
ID: 40216342
Hi Nibbler

OK, so your machine doesn't recognise the SQL server.
Is the SQL server a named instance? If not take away the \MSSQLSERVER from the connection string
Is your SQL Server on the network as "SERVERDB"? Probably not.

Here is the SQL connection format.
sqlcmd -S <ComputerName>\<InstanceName>

This EE article may be helpful too...
http://www.experts-exchange.com/Database/MS-SQL-Server/SQL_Server_2008/Q_26765525.html

Hope this helps

Tony
0
 
LVL 25

Assisted Solution

by:Mohammed Khawaja
Mohammed Khawaja earned 167 total points
ID: 40216366
MSSQLSERVER is the default instance.  Go to your Control Panel and look at services.  If you only see MS SQL Server service then you need to connect to SERVERNAME only and no instance name is required.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

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