Solved

SQLCMD not executing correctly when using a batch file

Posted on 2013-05-10
5
464 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 59

Expert Comment

by:Kevin Cross
Comment Utility
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 68

Accepted Solution

by:
Qlemo earned 500 total points
Comment Utility
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 59

Expert Comment

by:Kevin Cross
Comment Utility
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
Comment Utility
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
Comment Utility
This resolved my problems.  Thanks for your help.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
OfficeMate Freezes on login or does not load after login credentials are input.
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now