# Run SQL from VBScript



## justinds89 (Jul 13, 2011)

Hello I have a batch file that works great, but I am wanting to turn it into a VBS script(which I am not familiar with yet) and ultimately turn it into an HTA graphical interface.

My main concern is I have no idea how to go about running SQL commands from VBS. I will post my batch script so you can see what I am working with.



@echo off
color 70
mode con:cols=100 lines=25
del F:\MismatchScript\OutputTemp.txt
cls
echo.
:task
echo Select a task:
echo =============
echo.
echo 1) Select Count From Serial Number Table
echo 2) Select Count From Temporary Serial Number Table
echo 3) Select Count From Optimum Ref Table
echo 4) Select Count From Serial Number Not In Optimum Ref Table
echo 5) Select Count From Optimum Object Ref Table Where Serial Number Not In Serial Number Table
echo 6) Select Serial Number From Optimum Object Ref Table Not In Serial Table
echo 7) Delete Serial Number From Optimum Object Ref Table
echo 8) Display Output Of All Commands
echo 9) Exit
echo.
set /p input=Type option: 
if "%input%"=="1" goto SNCount
if "%input%"=="2" goto TSNCount
if "%input%"=="3" goto OORCount
if "%input%"=="4" goto SNNOORCount
if "%input%"=="5" goto OORSNNSNCount
if "%input%"=="6" goto SSNOORef
if "%input%"=="7" goto DSNOORef
if "%input%"=="8" goto DOACommands
if "%input%"=="9" exit

:SNCount
echo.
echo Count From Serial Number Table | F:\MismatchScript\Wtee.exe -a OutputTemp.txt
SQLPLUS.EXE -s DCSI/[email protected]**** @F:\MismatchScript\SNCount.SQL | F:\MismatchScript\Wtee.exe -a OutputTemp.txt
goto task

:TSNCount
echo.
echo Count From Temporary Serial Number Table | F:\MismatchScript\Wtee.exe -a OutputTemp.txt
SQLPLUS.EXE -s DCSI/[email protected]**** @F:\MismatchScript\TSNCount.SQL | F:\MismatchScript\Wtee.exe -a OutputTemp.txt
goto task

:OORCount
echo.
echo Count From Optimum Ref Table | F:\MismatchScript\Wtee.exe -a OutputTemp.txt
SQLPLUS.EXE -s DCSI/[email protected]**** @F:\MismatchScript\OORCount.SQL | F:\MismatchScript\Wtee.exe -a OutputTemp.txt
goto task

:SNNOORCount
echo.
echo Count From Serial Number Not In Optimum Ref Table | F:\MismatchScript\Wtee.exe -a OutputTemp.txt
SQLPLUS.EXE -s DCSI/[email protected]**** @F:\MismatchScript\SNNOORCount.SQL | F:\MismatchScript\Wtee.exe -a OutputTemp.txt
goto task

:OORSNNSNCount
echo.
echo Count From Optimum Ref Table Where Serial Number Not In Serial Number Table | F:\MismatchScript\Wtee.exe -a OutputTemp.txt
SQLPLUS.EXE -s DCSI/[email protected]****@F:\MismatchScript\OORSNNSNCount.SQL | F:\MismatchScript\Wtee.exe -a OutputTemp.txt
goto task

:SSNOORef
echo.
echo Select Serial Number From Optimum Object Ref Table Not In Serial Table | F:\MismatchScript\Wtee.exe -a OutputTemp.txt
SQLPLUS.EXE -s DCSI/[email protected]**** @F:\MismatchScript\SSNOORef.SQL | F:\MismatchScript\Wtee.exe -a OutputTemp.txt
goto task

SNOORef
echo.
echo Delete Serial Number From Optimum Object Ref Table | F:\MismatchScript\Wtee.exe -a OutputTemp.txt
SQLPLUS.EXE -s DCSI/[email protected]**** @F:\MismatchScript\DSNOORef.SQL | F:\MismatchScript\Wtee.exe -a OutputTemp.txt
goto task

OACommands
echo.
echo Displaying Output Of All Commands
F:\MismatchScript\OutputTemp.txt
goto task


----------

