milani_lucie
asked on
Help needed regarding OSQL utility !!
Hi,
I have
D:\Tables
D:\SPs
directories. In D:\Tables, I have create tables scripts. Similarly in D:\SPs, I have create stored procedures scripts.
I have written a .CMD file to install these scripts in the database - creating tables / creating stored procedures etc...
D:\Sample.CMD
============
echo ---------------
echo --- Setup START
echo ---------------
FOR %%f IN
(
..\Tables\*.sql
..\SPs\*.sql
) DO (echo Executing %%f) & (osql -E -n -S localhost -d Sample -w 8192 -i %%f) || (echo Error %%f & exit)
echo ---------------
echo --- Setup END
echo ---------------
In this script:
Server - localhost
Database - Sample
This is NOT working properly when i double click on this file. Can you please FIX the above program and make it working ? BTW: when i double click on the file, it is showing the results and disappearing quickly. Can you make it stand by until i press any key ?
Thanks
I have
D:\Tables
D:\SPs
directories. In D:\Tables, I have create tables scripts. Similarly in D:\SPs, I have create stored procedures scripts.
I have written a .CMD file to install these scripts in the database - creating tables / creating stored procedures etc...
D:\Sample.CMD
============
echo ---------------
echo --- Setup START
echo ---------------
FOR %%f IN
(
..\Tables\*.sql
..\SPs\*.sql
) DO (echo Executing %%f) & (osql -E -n -S localhost -d Sample -w 8192 -i %%f) || (echo Error %%f & exit)
echo ---------------
echo --- Setup END
echo ---------------
In this script:
Server - localhost
Database - Sample
This is NOT working properly when i double click on this file. Can you please FIX the above program and make it working ? BTW: when i double click on the file, it is showing the results and disappearing quickly. Can you make it stand by until i press any key ?
Thanks
ASKER
echo ---------------
echo --- Setup START
echo ---------------
FOR %%f IN
(
"..\Tables\*.sql"
"..\SPs\*.sql"
) DO (echo Executing %%f osql -E -n -S localhost -d Sample -w 8192 -i "%%f" if errorlevel 1 (echo Error %%f exit /b))
echo ---------------
echo --- Setup END
echo ---------------
This is NOT working. Can you please verify my code ? Please test on your side.
Thanks
echo --- Setup START
echo ---------------
FOR %%f IN
(
"..\Tables\*.sql"
"..\SPs\*.sql"
) DO (echo Executing %%f osql -E -n -S localhost -d Sample -w 8192 -i "%%f" if errorlevel 1 (echo Error %%f exit /b))
echo ---------------
echo --- Setup END
echo ---------------
This is NOT working. Can you please verify my code ? Please test on your side.
Thanks
ASKER
I have gone to command prompt and how to open the file ? Just type the name of the file ? Like this ?
C:\>Sample.CMD
C:\>Sample.CMD
ASKER
C:\>Sample.cmd
---------------
--- Setup START
---------------
The syntax of the command is incorrect.
C:\>
---------------
--- Setup START
---------------
The syntax of the command is incorrect.
C:\>
please try this:
echo ---------------
echo --- Setup START
echo ---------------
FOR %%f IN (..\Tables\*.sql ) DO (echo Executing %%f osql -E -n -S localhost -d Sample -w 8192 -i "%%f" if errorlevel 1 (echo Error %%f exit /b))
FOR %%f IN (..\SPs\*.sql) DO (echo Executing %%f osql -E -n -S localhost -d Sample -w 8192 -i "%%f" if errorlevel 1 (echo Error %%f exit /b))
echo ---------------
echo --- Setup END
echo ---------------
ASKER
Hi angelIII:
Here is the error i have caught...
C:\>Sample.cmd
---------------
--- Setup START
---------------
) was unexpected at this time.
C:\>
Here is the error i have caught...
C:\>Sample.cmd
---------------
--- Setup START
---------------
) was unexpected at this time.
C:\>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, forgot to remove the ECHO I put in for testing, currently the osql command will only be shown, not executed. Just remove the capitalized ECHO in front of the osql command.
Anyway, try this:
Open in new window