Skip to content Skip to sidebar Skip to footer

Process File With For Command In Alphabetical Order

I must run n query SQL for update more database. I created a batch file to help me in this activity but the queries are not executed ordered by name. I use this batch command: for

Solution 1:

Only reason for the FOR command not enumerating files in name order is that the file system is not NTFS. FAT filesystem enumerate files in drop order.

So use explicit name order enumeration

for /F "tokens=*" %%i in('dir /b /on *.sql')do (
    sqlcmd -S .\istance -U username -P password -d dbname -i %%i -o .\%%i.log
)

Post a Comment for "Process File With For Command In Alphabetical Order"