Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I have 2 SQL script say 1.sql and 2.sql . I want to use a Batch file to fist check the registry for the application version. Then based on the condition

VB
If version = 1.0.0040
  Run 2.sql
Else
  Run both 1.sql and 2.sql

1.sql creates Database and some other objects
2.sql modifies some objects

the Registry entry should be check on my local system,and the Database is on a remote machine on the network.

Please Help ....

additional information copied from comment below
This is the script I could come up with but PRoductVersion should have the registry value so that I can compare
@echo off

ECHO Enter Login User Details:
SET /P USER=User Name e.g. (DomainName\DomainUserName) [sa]: 
IF "%USER%"=="" SET USER="sa"
Echo Setting UserName to : %USER%

SET /P PWD=Password :

SET /P ProductVersion = ....................

IF ProductVersion = 1.0.0040 (

echo ..........................
echo Starting database creation
echo ..........................

sqlcmd -dSATDB -iSAT11_SQLscript.sql -ocreate_databases_log.txt

)

Else (

echo ..........................
echo Starting folder creation
echo ..........................

mkdir "D:\SAT\DATA"
mkdir "D:\SAT\BACKUP"

echo ..........................
echo Starting database creation
echo ..........................

sqlcmd -dSATDB -iSAT10_SQLscript.sql -ocreate_databases_log.txt
sqlcmd -dSATDB -iSAT11_SQLscript.sql -ocreate_databases_log.txt

)

GO
echo end of database creation

pause
Posted
Updated 2-Sep-14 3:18am
v3
Comments
Beginner_JK 2-Sep-14 8:43am    
This is the script I could come up with but PRoductVersion should have the registry value so that I can compare

@echo off

ECHO Enter Login User Details:
SET /P USER=User Name e.g. (DomainName\DomainUserName) [sa]:
IF "%USER%"=="" SET USER="sa"
Echo Setting UserName to : %USER%

SET /P PWD=Password :

SET /P ProductVersion = ....................

IF ProductVersion = 1.0.0040 (

echo ..........................
echo Starting database creation
echo ..........................

sqlcmd -dSATDB -iSAT11_SQLscript.sql -ocreate_databases_log.txt

)

Else (

echo ..........................
echo Starting folder creation
echo ..........................

mkdir "D:\SAT\DATA"
mkdir "D:\SAT\BACKUP"

echo ..........................
echo Starting database creation
echo ..........................

sqlcmd -dSATDB -iSAT10_SQLscript.sql -ocreate_databases_log.txt
sqlcmd -dSATDB -iSAT11_SQLscript.sql -ocreate_databases_log.txt

)

GO
echo end of database creation

pause

1 solution

you can also map your remote folder with pushd <remote folder=""> and unmap it when you finish with popd.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900