?
Solved

MS SQL 2008 error when trying to execute script.

Posted on 2014-07-24
3
Medium Priority
?
942 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 35

Accepted Solution

by:
ste5an earned 668 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 664 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 668 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

752 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