Solved

SQLCMD not executing correctly when using a batch file

Posted on 2013-05-10
5
480 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 70

Accepted Solution

by:
Qlemo earned 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

622 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