cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
COSMED
Level 4

I can't connect to SQL after I istall it

Hi,

I am doing an installation of SQL Server Express 2008 R2 from my installscript project. After this installation I need to connect to my installed database instance and run some sql scripts.

I execute a batch file which connects to the database via sqlcmd. This does not work. However, if I run the batch file after the installshield has exited, everything is fine and my sql scripts are executed.

I think the installshield is somehow holding an open connection - because I can connect after it finishes. But why is that? I am not using any SQL functionality in my project (instead I use my own batch file to do the database work).


Hope you can help. Thanks in advance.
Labels (1)
0 Kudos
(5) Replies
vdonga
Moderator Moderator
Moderator

Hi,

How are you trying to run the batch file. Is it through a custom action. If yes, please make sure that the action is sequenced properly.

Thanks.
0 Kudos
COSMED
Level 4

Thank you for your reply.

I execute bat file after SQL Installation using a custom action. The problem is not the sequentiality...
0 Kudos
rguggisberg
Level 13

rossellag wrote:
Thank you for your reply.

I execute bat file after SQL Installation using a custom action. The problem is not the sequentiality...


I wouldn't be to hasty to dismiss the sequentiality.
You should probably be using a deferred custom action... which means you need to take special care if you are expecting properties to be available to it.
Remove the LAAW_OPTION_HIDDEN option if you are using it to launch the bat file and put some ECHO and PAUSE statements in the bat file to see what is going on.
1. Are the arguments (if any) being passed to it correctly.
2. Is there some redirection (64 bit) taking place for folders and/or registry?
3. Is it being launched 'As administrator' and thereby the current directory is getting changed under you?
Can you look into this and then post the results and the bat file?
0 Kudos
COSMED
Level 4

The problem is that SQLCMD is not recognized as command.
Probably the environment variables are updated only when the installation finishes. I think this because when I restart the setup, the batch file works fine.


The batch file works only if it is not executed immediately after the installation of SQL Server
0 Kudos
rguggisberg
Level 13

You are correct... the environment variables are updated when the installation finishes.
You can do something like below in your bat file (after installing SQL).
Be a little careful with this. I think it will work for SQL 2008... not sure about SQL 2012 (\100).
You may want something different IF ERRORLEVEL 1... or you may just delete all of that.

SQLCMD /? > nul 2> nul
IF NOT ERRORLEVEL 1 GOTO :eof
SETX Path "%path%;%ProgramFiles%\Microsoft SQL Server\100\Tools\Binn" 2>nul
IF ERRORLEVEL 1 (
COLOR E0
ECHO.
ECHO.On this OS you must manually set the Path environment variable to include
ECHO.%ProgramFiles%\Microsoft SQL Server\100\Tools\Binn
ECHO.Edit that as follows:
ECHO.Right click on 'My Computer'
ECHO. Properties
ECHO. Advanced
ECHO. Environment Variables
PAUSE
)
GOTO :eof
0 Kudos