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 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:

http://tinypic.com/view.php?pic=29za3gn&s=5

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

EDIT:

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

sqlcmd -Snp:\\.\pipe\MSSQL$SQLEXPRESS\sql\query
share|improve this question

1 Answer 1

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

 
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.