473,396 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

XP batch file loop help

Hello,
I am trying to run all SQL scripts (with no params) in the same folder as the batch file is. I have not done much with batch files before but I think I have gotten close. It seems to work if I hard code the FILENAME.sql but will of course only work for the file I hard coded. What I need is to get the present file name from the loop and put it in to the FILENAME.sql so it will run that sql script. Hope this makes some sense and here is what i have so far:

@echo off

SET ServerName=
SET /P ServerName= Please enter the Server Name:
SET DatabaseName=
SET /P DatabaseName=Please Enter Database Name:

for /f %%a in ('dir /b *.sql') do call :process
goto :eof

:process
osql -E -S %ServerName% -d %DatabaseName% -n -i FILENAME.sql > Report.txt

Thanks
May 16 '07 #1
2 9679
Banfa
9,065 Expert Mod 8TB
Try this

Expand|Select|Wrap|Line Numbers
  1. @echo off 
  2.  
  3. SET ServerName= 
  4. SET /P ServerName= Please enter the Server Name: 
  5. SET DatabaseName= 
  6. SET /P DatabaseName=Please Enter Database Name: 
  7.  
  8. for /f %%a in ('dir /b *.sql') do call :process %%a
  9. goto :eof
  10.  
  11. :process
  12. osql -E -S %ServerName% -d %DatabaseName% -n -i %1 > Report.txt
  13. goto :eof
  14.  
  15.  
May 16 '07 #2
Great, thanks works perfect.
May 16 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: VM | last post by:
In my Windows app, I'm running a batch process that's composed of a FOR loop that'll run 15,000 times (datatable row count), copy cthe data of each row -3 fields- to a struct, and send the strct to...
6
by: Charles Neitzel | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
1
by: Charles | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
4
by: | last post by:
Hello, I am attempting to convert multiple .wav files to the .flac format via a batch script. I know that this can be done with numerous software implementations automatically for me; however, i am...
2
by: eric1025 | last post by:
I have a form with a command button. When the command button is clicked, it runs a batch file via the Shell command. The batch file is run with a few variables coming from the database such as %1...
0
by: Raakish | last post by:
Hello I am trying to use a batch file to run a DTS program that I had created. Below is the Batch File code: REM Type: Batch File REM Created by: Raakish REM Contact: raakish22@gmail.com REM...
14
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.