Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to schedule a backup for my database for SQL 2008 express. I found a nice stored procedure for this job. I made a bat file for it and I want to run it, but the following sqlcmd statement fails :

sqlcmd -S '.\SQLEXPRESS' -Q "EXEC sp_BackupDatabases @databaseName='BonusPoint', @backupLocation='C:\DBBackup\', @backupType='F'"

I also tried with the username and the password:

sqlcmd -S '.\SQLEXPRESS' -U 'sa' -P '*******' -Q "EXEC sp_BackupDatabases @databaseName='BonusPoint', @backupLocation='C:\DBBackup\', @backupType='F'"

But I'm getting the following error:

The database is in the same machine and I can connect to the database via SSMS.


Finaly I succesfully connected to the DB via sqlcmd with the following statement:

sqlcmd -Snp:\\.\pipe\MSSQL$SQLEXPRESS\sql\query
share|improve this question
up vote 0 down vote accepted

The issue with your original attempts is that you had -S '.\SQLEXPRESS' where SQLCMD doesn't like the single quotes. it you would of used double quotes, such as -S ".\SQLEXPRESS", it would of likely worked.

share|improve this answer
You're right it's working just fine. The interesting in it is that I found the snippet from a random forum and there they saying that the snippet is working fine. Is there some differences between the sqlcmd versions? – Lóri Nóda Sep 8 '13 at 21:23
I can't say for certain whether there is a difference in versions of SQLCMD in regards to this. But I just did a quick test though comparing the regular command prompt with the powershell prompt. It looks like the powershell prompt works just fine with the single quotes where the command prompt does not. I suspect it is just a difference in how the two different prompts treat quotes. – Ian Chamberland Sep 9 '13 at 17:20

Your Answer


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.