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

Restarting SQL after install & run more SQL scripts

My installscript MSI requirements:

(1) Install SQL Express 2005
(2) Run some scripts
(3) Restart SQL
(4) Run some more scripts
(5) Install my application

I suspect that I will need to use some built-in or custom actions to do this but I’m not sure how.

(1) I need a custom action that will Restart SQL
(2) I need to know how/where to place the Restart action
(3) How to have a second group of SQL scripts connect and execute after the restart

Thanks for the help
Labels (1)
0 Kudos
(5) Replies
_shielder_
Level 6

The background post on why I need to restart SQL is here.

The solution:

My install proceeds as a normal SQL install with scripts but finishes with an extra script at end of the install.

I created four custom actions, SQLstop, SQLstart, SQLscript, SQLscript64 and are sequenced in the Installation Execute folder just after ISSQLServerInstall.

SQLstop & SQLstart use the command line “net stop MSSQL$MYDBINSTANCE”, Deferred Execution

SQLscript & SQLscript64 (only difference is the program files (x86) path)

Command Line:
"c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\sqlcmd.exe" -S .\MYDBINSTANCE -d MyDB -E -i "C:\Program Files (x86)\MyCompany\MyApp\SqlCLRScript.sql"

In-Script Execution: Commit Execution in System Context

SQLscript & SQLscript64 use sqlcmd.exe to run a script from a file to complete my CLR install after the restart of SQL Server.

And finally, I used VersionNT64 as a condition for running the custom actions.


If you found this post helpful support the “Code{the final solution}” group. Click the "Like" button and help spread the word…
0 Kudos
Christopher_Pai
Level 16

I know you can create a template.ini to feed into SQL Server Express setup to automate it when silent. I wonder if it exposes any settings that would enable CLR by default that way when you get to your install you can just run your scripts.

Also if the user doing access will have access to the database I think you could do this without any custom actions. You could create a script to execute during logon ( the dialog where you test your connection ) and then create a component that has ServiceControl actions to stop and start SQL for you. Then IS would execute your sql scripts later on.
0 Kudos
_shielder_
Level 6

Thanks Christopher,

This was actually a continuation of an earlier post. See here. The whole problem started because WOW64 Servers “Require” a SQL restart to enable CLR. I’m not sure about your second suggestion but maybe.

Thanks again…
0 Kudos
Christopher_Pai
Level 16

Btw, have you ever played with the SAC utility (Surface Area Configuration)? You will find it in your 90\shared directory. You run a little GUI to configure SQL server and export it to an XML file. You can then write a custom action that calls 90\shared\sac.exe along with your XML file and a few switches and it'll reconfigure the instance for you. I don't believe you have to restart the instance when you go this route.
0 Kudos
_shielder_
Level 6

You may be right but this Microsoft post is what I went by. I also didn't see any workarounds on the web. Cheers!

http://msdn.microsoft.com/en-us/library/ms175193.aspx
0 Kudos