Run List of .sql files from a batch file

  • I have a folder which consists of set of .sql files which may be a procedure,table script or any sql script.I need a batch file with server,user,pwd,databse to be given with in the batch file(hard coded) but the .sql files in the folder can be any name.on executing the batch file all the files in the folder must be run on the server specified in the batch file with the error log files created in the folder.

  • ECHO OFF

    CLS

    SET FilePath=C:\MySQLFiles\*.sql

    SET MyServer=NameOfTheServer

    SET MyLogin=LoginName

    SET MyPassword=Password

    SET MyDatabase=DefaultDB

    FOR %%i IN (%FilePath%) DO osql -S%MyServer% -U%MyLogin% -P%MyPassword% -d%MyDatabase% -i%%i -o%%i.log

    --Ramesh


  • Thanx a lot

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply