• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 526
  • Last Modified:

SQLCMD not executing correctly when using a batch file

I'm trying to backup a small SQL database using task scheduler in Windows 7.  When I run the SQL command that I have created in the command prompt, it runs successfully.  If I try and run that same command in a batch file, the command just executes over and over in the command prompt until you cancel it.  What am I missing?  I am using SQL Server Express 2008.
0
bnob99
Asked:
bnob99
  • 2
  • 2
1 Solution
 
Kevin CrossChief Technology OfficerCommented:
Hi.

Did you turn the echo off? If not, do so:
@echo off

Open in new window

MSDN: http://msdn.microsoft.com/en-us/library/ms180944.aspx

Let me know if that helps.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Probably you have named the batch file sqlcmd, and so sqlcmd calls itself. You can
a) rename the batch file
b) use sqlcmd.exe in the batch file to make sure the application is run
c) provide the exact path to sqlcmd.exe with the call.
0
 
Kevin CrossChief Technology OfficerCommented:
Good call Q. I thought the batch was echoing the SQLCMD and so repeating; however, your theory sounds more viable.
0
 
bnob99Author Commented:
Thanks for the suggestions.  I've had jury duty all week so I will try the suggestions on Monday.
0
 
bnob99Author Commented:
This resolved my problems.  Thanks for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now