Command Line, File Name for each script executed. SQL

Visual Basic .Net

I have the following files in my folder:

Script1.sql
Script2.sql
Script3.sql

The below command executes each script successfully:

@echo off

set /p sname= Please enter the servername:
set /p dbname= Please enter the databasename:

ECHO started the batch process at %TIME%  >output.txt

for %%f in (*.sql) do (
sqlcmd.exe  -S %sname% -d %dbname% -i %%f  >>output.txt

%~f0"

    )
pause

Results are

(1 rows affected)

(3 rows affected)

(2 rows affected)

What I would like to know is how can i input the file name after each file is executed and this name stored in the output.txt file ie

(1 rows affected)

Script1.sql

(3 rows affected)

Script2.sql

(2 rows affected)

Script3.sql

Any help appreciated

Remus Rusanu

Just output the file name, what's problem?

for %%f in (*.sql) do (
   echo %%~nf >> output.txt
   sqlcmd.exe  -S %sname% -d %dbname% -i %%f  >>output.txt
)

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

What is the function of @ at the command line after a file name

분류에서Dev

How is a bash script executed via its filename as command name with and without shebang?

분류에서Dev

What is the actual command executed when running a script with a shebang as its name with same arguments?

분류에서Dev

How to move a file with a space in the name? (command-line)

분류에서Dev

Return last command executed in shell-script

분류에서Dev

Command Line input for Python Script

분류에서Dev

How would I read the contents of a text file and run a command for each line?

분류에서Dev

What command(s) will feed a tab-delimited text file and cut each line to 80 characters?

분류에서Dev

How can I pass parameter in Talend exported job, through command line or bash script file?

분류에서Dev

Bash - pair each line of file

분류에서Dev

A command to output each line forward then backwards

분류에서Dev

Runinng command on each line and export in the same way

분류에서Dev

Shell script : each line called twice?

분류에서Dev

Understanding a Perl one-line command in a script

분류에서Dev

PHP executing background command line script

분류에서Dev

Optional command line argument in R script

분류에서Dev

Change line in text file from other text file with command line

분류에서Dev

Frequency of specific symbols on each line of a text file

분류에서Dev

Grep last N characters of each line in a file

분류에서Dev

Number of same line in each text file

분류에서Dev

sed unterminated 's'command modify line of file

분류에서Dev

Command line SVG and image file viewer in Linux?

분류에서Dev

Adding file path as Command Line Argument

분류에서Dev

add hash to a file using command line

분류에서Dev

Delete locked file/folder from command line

분류에서Dev

Align rows in text file with command line

분류에서Dev

Run php File in Browser from Command Line

분류에서Dev

Add and number blank line above each line in a file

분류에서Dev

Extract line from a file in shell script

Related 관련 기사

  1. 1

    What is the function of @ at the command line after a file name

  2. 2

    How is a bash script executed via its filename as command name with and without shebang?

  3. 3

    What is the actual command executed when running a script with a shebang as its name with same arguments?

  4. 4

    How to move a file with a space in the name? (command-line)

  5. 5

    Return last command executed in shell-script

  6. 6

    Command Line input for Python Script

  7. 7

    How would I read the contents of a text file and run a command for each line?

  8. 8

    What command(s) will feed a tab-delimited text file and cut each line to 80 characters?

  9. 9

    How can I pass parameter in Talend exported job, through command line or bash script file?

  10. 10

    Bash - pair each line of file

  11. 11

    A command to output each line forward then backwards

  12. 12

    Runinng command on each line and export in the same way

  13. 13

    Shell script : each line called twice?

  14. 14

    Understanding a Perl one-line command in a script

  15. 15

    PHP executing background command line script

  16. 16

    Optional command line argument in R script

  17. 17

    Change line in text file from other text file with command line

  18. 18

    Frequency of specific symbols on each line of a text file

  19. 19

    Grep last N characters of each line in a file

  20. 20

    Number of same line in each text file

  21. 21

    sed unterminated 's'command modify line of file

  22. 22

    Command line SVG and image file viewer in Linux?

  23. 23

    Adding file path as Command Line Argument

  24. 24

    add hash to a file using command line

  25. 25

    Delete locked file/folder from command line

  26. 26

    Align rows in text file with command line

  27. 27

    Run php File in Browser from Command Line

  28. 28

    Add and number blank line above each line in a file

  29. 29

    Extract line from a file in shell script

뜨겁다태그

보관