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