sql server - How do I call a stored procedure on each of the files in a directory as a parameter? -


i'm green batch scripting, client doesn't allow use of ssis, tool can turn right now...

i have folder of flat files, , want call stored procedure on each file.

i can loop through files, , can call sqlcmd, can't figure out how pass name of file stored procedure.

here's have:

pushd d:\test /f "delims=" %%i in ('dir /b') sqlcmd -s servername -u username -p pword -q "exec db.schema.sp $(the_filename)" -v the_filename = %%i popd 

but i'm getting error: incorrect syntax near '%'

what correct syntax?

try this:

pushd d:\test /f "delims=" %%i in ('dir /b') (     sqlcmd -s servername -u username -p pword -q "exec db.schema.sp '%%i'" ) popd 

the parentheses not required, use them added clarity.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -