Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQLCMD not executing correctly when using a batch file

Posted on 2013-05-10
5
Medium Priority
?
496 Views
Last Modified: 2013-05-26
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
Comment
Question by:bnob99
  • 2
  • 2
5 Comments
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 39157069
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
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 39157210
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
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 39157330
Good call Q. I thought the batch was echoing the SQLCMD and so repeating; however, your theory sounds more viable.
0
 

Author Comment

by:bnob99
ID: 39175883
Thanks for the suggestions.  I've had jury duty all week so I will try the suggestions on Monday.
0
 

Author Closing Comment

by:bnob99
ID: 39197724
This resolved my problems.  Thanks for your help.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

782 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