Solved

MS SQL 2008 error when trying to execute script.

Posted on 2014-07-24
3
756 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
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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.

911 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

21 Experts available now in Live!

Get 1:1 Help Now