It is of a common practice to write a batch file to execute the commands using some command line utilities like OSQL. And to provide the required parameters to that command line utility, we just set some variable in the command file and pass them as parameters to the batch file containing the commad to be executed.
Suppose we have a batch file which executes a OSQL command by taking few parameters like ServerName, Database name, Username, password etc. So we just run that batch file probably by providing all the required parameters as:
MyBatchFile.bat computername SQLUser SQLUSERPWD DBName
And in the batch file we make use of these parameters by their order in which they are being passed as:
osql -U%2 -P%3 -S%1 -d%4
This works absolutely fine till we have total only upto 9 (nine) parameters to be passed to the batch file and to be used in that file. But if we pass more than nine parameters and try to use them in the command as %10 oR %11 ..so on, it would not work. %10 will be considered as FirstParameter0 & %11 as SecondParameter1 i.e. if %1 = MYMACHINE, then %10 will be = MYMACHINE0.
So to have more than 9 parameters in the batch file, we make use of SHIFT function as:
:In this way we can move to any index of the parameters list, It will start from the first parameter and then by shifting it to right direction we can reach upto the last parameter. And then in the command we can use them as:
osql -U%TWO% -P%THREE% -S%ONE% -d%FOUR% %TEN%…….