I need a DOS command or a batch (.bat) file that I can execute to run all the * .sql scripts in the directory and its subdirectories. What will be the solution?
Below you will get
for /r %f in (*.sql) do echo %f
Run from the command line, which will print the names of all the SQL files in the current directory and in all subdirectories.
Then replace sqlcmd <connection args> -i%fon echo %fthe scripts.
sqlcmd <connection args> -i%f
echo %f
Hope this helps.
. sql . output.txt , . :
, [YourPath] "\"
SET = [YourDatabase]
SET ScriptsPath = [YourPath]
SET ServerInstance = [YourServerName\YourInstanceName]
IF EXIST "% ScriptsPath% output.txt" del "% ScriptsPath% output.txt"
NUL > "% ScriptsPath% output.txt"
FOR/R "% ScriptsPath%" %% G IN (*.sql) DO (
sqlcmd -d% % -S% ServerInstance% -i "%% G" -o "%% G.txt"
..................................................................................... → "% ScriptsPath% output.txt"
echo : "%% G" → "% ScriptsPath% output.txt"
copy "% ScriptsPath% output.txt" + "%% G.txt" "% ScriptsPath% output.txt"
del "%% G.txt"
)
for %f in ("c:\path\to\dir\*.sql") do sqlcmd -S [SERVER_NAME] -d [DATABASE_NAME] -i "%f" -b
for. , , DOS , , DOS "cmd.exe Windows XP", - :
for
cmd.exe
for /r . %f in (*.sql) do @echo %f
, . , , , SQL, echo.
echo
for /?.
for /?
Source: https://habr.com/ru/post/1734885/More articles:Weird Javascript Bug (jQuery) in a simple test page - javascripthttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1734881/shared-authentication-between-saascloud-web-application-and-desktop-application&usg=ALkJrhgFtuQyz3wy25bfbS_7Mvhb8SaFNghow to activate a trigger after all voluminous inserts in mysql - mysqljQuery: not () issue - jqueryNPTL binding for pthread pthread_condattr_setclock - pthreadsHow do you live - filter NSArray or NSMutableArray? - cocoaASP.NET/JavaScript - Ajax call, how? - javascriptJFace Label Provider Overview - eclipseHow to export code formatting settings in Delphi 2010? - delphiАутентификация форм с помощью sqlite - asp.net-mvcAll Articles