Running all sql scripts in folder from bat file

  • Hi guys,

    I'm trying to create a bat or cmd file that can run all the sql scripts in a folder, which is very useful for my sprocs folder especially. If I run the following script from command line it works fine:

    FOR %f IN (*.sql) DO OSQL -U username -P password -S localhost -d databasename -n -m-1 -b -i "%f"

    But if I put it in a .bat or .cmd file then it blows up:

    f" was unexpected at this time.

    How do I fix this?

    Thanks!

    Justin

  • Hi,

    you need two percent signs for your variable. (%%f instead of %f)

    Hope this helps 🙂

  • That did it, thank you sir!!

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

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