How to append batch file command to a strings(file names) using batch file -


i'm in process of creating batch file list names of sql scripts in folder text file. plan convert text file batch file can use execute scripts in server. have following string appended before each file name while creating initial text file

sqlcmd -s %mssqlserver_name% -d %mssqlserver_dbname% -i 

this batch file command , appended before each file names. eg:

sqlcmd -s %mssqlserver_name% -d %mssqlserver_dbname% -i 001_alter_person.sql 

the code i'm using is

set mssqlserver_name = "%mssqlserver_name%" set %mssqlserver_dbname = "%mssqlserver_dbname%"  set myvar=sqlcmd -s %mssqlserver_name% -d %mssqlserver_dbname% -i  /r . %%g in (*.sql) echo %myvar% %%~nxg >> d:\test.txt  pause 

out put i'm getting

sqlcmd -s  -d  -i 015_alter_vboard_papers.sql  

let me know how tackle this

set myvar=sqlcmd -s %%mssqlserver_name%% -d %%mssqlserver_dbname%% -i 

should cure problem - % escapes %

note spaces significant in variable names, set var = somethingwill set var[space] [space]something

set %varname%=... rare -it sets variablename (contents of varname).

even more rare have unbalanced %... not sure work @ all...


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -