I am trying to use a single .bat file for: 1) install SQL Server 2008 R2 Express from SQLEXPR_x64_ENU.exe on 64-bit Windows 7 Professional machines and 2) run some .sql scripts after installation is complete.
It seems that if sqlcmd is run from the same .bat file that started the installation, then sqlcmd fails with the following error: "sqlcmd" is not recognized as an internal or external command, operating program, or batch file. "
If the install and .sql scripts are run from separate .bat files, then I have no problems (and therefore, I know that the problem is not with sqlcmd syntax). I tried using one byte and running sqlcmd commands in a new window (beginning cmd / c "sqlcmd ...") and calling the second .bat file containing sqlcmd commands from the source .bat file (\ filepath \ file.bat), but the same error occurs in each case.
I do not want the user to run more than one .bat file, because this opens up problems with launching .bat files in the wrong order, by starting one and not the other, etc.
My two questions are:
- Does anyone know why this is happening?
- Is there a solution that involves running only one .bat file?
source share