Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to use a simple batch script to backup a local instance of SQL Express 2012, as follows:

@echo off
SET BACKUP_DIR=E:\BackupData
SET SERVER=.\\sqlexpress
set dom=%date:~0,2%
set month=%date:~3,2%
set year=%date:~6,4%
set file=%year%-%month%-%dom%
sqlcmd -S %SERVER% -d master -Q "exec sp_msforeachdb 'BACKUP DATABASE [?] TO DISK=''%BACKUP_DIR%\?.Full.%file%.bak'''

The script is failing to run with the following error:

Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Client unable to establish connection due to prelogin failure.

This is on Server 2008 R2, my SQL database (on localhost) instance is named SQLEXPRESS. There is an instance of SQL Express 2008 on the system (hence client 10.0).

The database is configured to use a trusted connection, and the .net desktop software deployed on our network PCs is able to access the database without any problem.

Am I missing something obvious here, I've done a fair amount of searching for this error message, and haven't found anything that has been particularly useful so far.

share|improve this question
    
Databases are not configured to use trusted connections, applications are configured to connect to databases with trusted connections. –  Justin Dearing Mar 21 '12 at 19:08

1 Answer 1

up vote 1 down vote accepted

Change remove one of the slashes in SET SERVER=.\\sqlexpress. It should be SET SERVER=.\sqlexpress

share|improve this answer
    
Thanks, that and the closing double quotes around the query were missing. –  Bryan Mar 22 '12 at 8:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.