Solved

MS SQL 2008 error when trying to execute script.

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

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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

717 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