batch file need help

July 13, 2010 at 17:24:05
Specs: Windows XP
Hi All,

I have a table in sql server which contains a column called flag. the column will have values either 1 or 0.

My requirement is

I need to check the value in the table . If the value is 1 then i will run a command and if the value is 0 then i run another comand.

How do we do this in batch file


See More: batch file need help

Report •


#1
July 13, 2010 at 18:20:32
@ECHO OFF
SET /p Value=<Value.txt
IF "%Value%"=="1" command
IF "%Value%"=="0" command

----

Just change "Value.txt" to the name of your file, and enter the commands where "command" is.

I don't know where the files are stored on an sql server, so you'll have to navigate to it yourself.


Report •

#2
July 14, 2010 at 10:45:08
Hi matt,

the values are stored in a table not in a file.

The values are stored in a table in Sql server.


Report •

#3
July 14, 2010 at 11:17:13
Is the table a text file?

If not, this probably won't get done in a batch.


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
July 14, 2010 at 11:41:01
Hi the table is not a text file.
But i think this can be done in batch. We can do a select on the table and store the value in a variable.

i am not sure if i am correct


Report •

#5
July 14, 2010 at 11:45:20
Post the first, let's say, 10 lines.


=====================================
Helping others achieve escape felicity

M2


Report •

#6
July 14, 2010 at 15:55:13
Ahh, sorry I'm not familiar with sql. If it's not saved in a txt file, or anything similar (dat), I'm not sure how you will be able to do this.

Sorry.

----

If you can store the value in a variable that is readable by a batch file (I'm not sure how that would work) just use the code:

IF "%var%"=="1" command
IF "%var%"=="0" command

I don't know if this is what you meant by "we can store the value in a variable" or not.


Report •

Ask Question