This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: SQL Scripts
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 23, 2009
10:00 PM
SQL Scripts
Hello All,
I am new to Installshield so not sure whether this is possible.
Can you run custom actions in between SQL scripts executing ?
As far as I can see the SQL scripts run together ordered by the order property in that table.
I am wanting to run a custom action between two of the SQL scripts but not sure how I separate the SQL routines to run individually and not as a group.
Any help greatly appreciated.
regards
Shaun
I am new to Installshield so not sure whether this is possible.
Can you run custom actions in between SQL scripts executing ?
As far as I can see the SQL scripts run together ordered by the order property in that table.
I am wanting to run a custom action between two of the SQL scripts but not sure how I separate the SQL routines to run individually and not as a group.
Any help greatly appreciated.
regards
Shaun
(5) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 24, 2009
09:46 AM
That is not possible. I am wondering why you need to run a custom action between SQL scripts.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 24, 2009
03:42 PM
Thanks for that confirmation. In the meantime I worked out a way to do what I wanted from within a SQL script itself.
Just the detail to curb your interest....
The install package installs an MDF and attachs it at the end of the process.
The problem is however that the database may exist on the detsination server and must be dropped first.
As this is the case the first SQL statement run is a DROP database (which removes MDF files in the database folder). After the database is dropped I need to move the new MDF file into the data folder before attaching it.
Ive managed to do the move using the xp_cmdshell extended stored procedure. Bu this was going to be the custom action I had running between SQL scripts.
Thansk again for the confirmation.
Just the detail to curb your interest....
The install package installs an MDF and attachs it at the end of the process.
The problem is however that the database may exist on the detsination server and must be dropped first.
As this is the case the first SQL statement run is a DROP database (which removes MDF files in the database folder). After the database is dropped I need to move the new MDF file into the data folder before attaching it.
Ive managed to do the move using the xp_cmdshell extended stored procedure. Bu this was going to be the custom action I had running between SQL scripts.
Thansk again for the confirmation.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 24, 2009
04:27 PM
I think that you should be able to accomplish your requirement using a single SQL script in the SQL Scripts view without having another custom action as follows:
[Code]IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'TestDatabase')
DROP DATABASE TestDatabase
GO
EXEC xp_cmdshell 'copy "C:\Test1\TestDatabase.mdf" "C:\Test2\TestDatabase.mdf"'
GO
EXEC xp_cmdshell 'copy "C:\Test1\TestDatabase_log.ldf" "C:\Test2\TestDatabase_log.ldf"'
GO
CREATE DATABASE [TestDatabase] ON (NAME = N'TestDatabase', FILENAME = N'C:\Test2\TestDatabase.mdf' , SIZE = 3, FILEGROWTH = 1) LOG ON (NAME = N'TestDatabase_log', FILENAME = N'C:\Test2\TestDatabase_log.ldf' , SIZE = 1, FILEGROWTH = 10%) FOR ATTACH
GO
[/Code]
[Code]IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'TestDatabase')
DROP DATABASE TestDatabase
GO
EXEC xp_cmdshell 'copy "C:\Test1\TestDatabase.mdf" "C:\Test2\TestDatabase.mdf"'
GO
EXEC xp_cmdshell 'copy "C:\Test1\TestDatabase_log.ldf" "C:\Test2\TestDatabase_log.ldf"'
GO
CREATE DATABASE [TestDatabase] ON (NAME = N'TestDatabase', FILENAME = N'C:\Test2\TestDatabase.mdf' , SIZE = 3, FILEGROWTH = 1) LOG ON (NAME = N'TestDatabase_log', FILENAME = N'C:\Test2\TestDatabase_log.ldf' , SIZE = 1, FILEGROWTH = 10%) FOR ATTACH
GO
[/Code]
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 24, 2009
04:32 PM
Yes I already have got this working along the lines you detailed.
Just provided that detail as you were wondering why I needed a custom action between scripts. Turns out I found the work around.
The xp_cmdshell procedure is an interesting one given you have to enable it and it forces the SQL connection to a user part of the sysadmin role in SQL Server.
Thats again
Just provided that detail as you were wondering why I needed a custom action between scripts. Turns out I found the work around.
The xp_cmdshell procedure is an interesting one given you have to enable it and it forces the SQL connection to a user part of the sysadmin role in SQL Server.
Thats again
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 27, 2010
02:29 PM
An FYI for anyone looking to certify their software via the Microsoft "Works with SQL Server 2008 Test": it is required that xp_cmdshell be turned off.