Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 6

Running SQLCMD

Hi there

I am writing a Installscript 2010 project and have a requirement to create/populate databases (SQLServer 2008) by connecting to a specified SQLServer from a remote machine.

The original solution was to use the the SQLView functionality (built-in to Installshield), but because there were so many SQL scripts (100+) which had to be run in order it was easier to run the already created batch file and pass in some command line params. Problem is the remote machine may not have SQLCMD.EXE installed, so I will detect a copy and install if necessary.

I launch the following Microsoft SQL Server 2008 Command Line Utilities-->SqlCmdLnUtils.msi and its pre-requisite Microsoft SQL Server 2008 Native Client-->sqlncli.msi during the installation. After these tools have been installed I should now be able to run the batch file containing SQLCMD, however this does not work because there is no environment path set e.g c:\program files\mssqlserver\tools\bin, so the batch file does not know where to pick up SQLCMD unless I explicitly tell it.

I set the environment variable with Installscript and refresh the environment with an API SendMessage call. However the batch file still does not know where SQLCMD is, unless I perform a reboot or re-install the installation.

Are you aware of any work around for this, without performing a re-boot? Perhaps I am going about this the wrong way.

BTW Which files does the SQLView functionality use?

Labels (1)
0 Kudos
(1) Reply
Level 6

I think the way round this is to write my own version of an SQLCMD.exe interfaces that already exist within the operating system, in this case Windows 2008.
0 Kudos