用自定義的SQL腳本創建SQL Server數據庫安裝例子

Creating a Sample Installation that Creates a SQL Server Database by Running Customized SQL Script
InstallShield 2009
 用自定義的SQL腳本創建SQL Server數據庫安裝例子
Project 項目
This information applies to the following project types: 此信息是用於下面的項目類型
• Basic MSI
• InstallScript MSI
The following procedure demonstrates how to create an installation that creates a SQL Server database through customized SQL script.
下面的過程展示瞭如何用自定義的SQL腳本創建SQL Server數據庫安裝
Task 任務
To create an installation that creates a SQL Server database on the target machine by running customized SQL script:
1. Create a new Basic MSI or InstallScript MSI project.新建一個基本MSI安裝腳本MSI工程。
2. In the View List under Behavior and Logic, click Property Manager.在視圖列表下的行爲和邏輯,點屬性管理。
3. Create a new property that has the following name:新建屬性名稱爲IS_SQLSERVER_DATABASE2
IS_SQLSERVER_DATABASE2
4. In the View List under Server Configuration, click SQL Scripts.在視圖列表下的服務器配置中,點SQL 腳本。
5. Add and configure a new SQL connection:
加入和配置新的SQL連接;
a. Right-click the SQL Scripts explorer and click New SQL Connection. InstallShield adds a new connection with the name NewConnection1 as the default name.
b. In the SQL Scripts explorer, click the NewConnection1 item, and then click the General tab.
c. In the Default Target Server Name (optional) box, type TESTSQLSERVER.
d. Clear the Create Catalog If Absent check box.
e. In the Connect using area, select the Server authentication using the Login ID and password below option.
f. In the Login ID box, type sa. Leave the Password box blank.
g. Click the Requirements tab.
h. Ensure that the Microsoft SQL Server check box is selected and the MySQL and Oracle check boxes are cleared.
6. Add and configure a new SQL script for NewConnection1:
爲NewConnnection1加入和配置新的SQL腳本
a. In the SQL Scripts explorer, right-click NewConnection1 and click New Script.
b. Change the name of the script to NewScript1.
c. In the SQL Scripts explorer, click NewScript1, and then click the Script tab.
d. In the script editor pane, add the following script:
CREATE DATABASE [TestDB] ON (NAME = N' TestDB', FILENAME = N'C:/Program Files/Microsoft SQL Server/MSSQL/data/testdb.mdf' , SIZE = 3, FILEGROWTH = 10%) LOG ON (NAME = N' TestDB_log', FILENAME = N'C:/Program Files/Microsoft SQL Server/MSSQL/data/testdb.ldf' , SIZE = 1, FILEGROWTH = 10%)
COLLATE SQL_Latin1_General_CP1_CI_AS
e. Click the Runtime tab.
f. In the Script Execution area, select the Run Script During Login check box and ensure that the Run Script During Install and Run Script During Uninstall check boxes are cleared.
7. Add and configure a second new SQL connection:
加入和配置第二個SQL連接
a. Right-click the SQL Scripts explorer and click New SQL Connection. InstallShield adds a new connection with the name NewConnection2 as the default name.
b. In the SQL Scripts explorer, click the NewConnection2 item, and then click the Advanced tab.
c. In the Target Catalog Property Name list, select IS_SQLSERVER_DATABASE2.
d. Click the General tab.
e. In the Catalog Name box, type TestDB.
f. Clear the Create Catalog If Absent check box.
g. In the Default Target Server Name (optional) box, type TESTSQLSERVER.
h. In the Connect using area, select the Server authentication using the Login ID and password below option.
i. In the Login ID box, type sa. Leave the Password box blank.
j. Click the Requirements tab.
k. Ensure that the Microsoft SQL Server check box is selected and the MySQL and Oracle check boxes are cleared.
8. Add and configure a new SQL script for NewConnection2:
爲NewConnnection2加入和配置新的SQL腳本
a. In the SQL Scripts explorer, right-click NewConnection2 and click New Script.
b. Change the name of the script to NewScript2.
c. In the SQL Scripts explorer, click NewScript2, and then click the Script tab.
d. In the script editor pane, add the following script:
CREATE TABLE TestTable (TestColumn1 CHAR NOT NULL PRIMARY KEY)
e. Click the Runtime tab.
f. In the Script Execution area, select the Run Script During Install check box and ensure that the Run Script During Login and Run Script During Uninstall check boxes are cleared.
When you run the installation, it creates the TestDB database and adds a table called TestTable to that database.
運行安裝,創建數據庫TestDB,並在庫中創建名稱爲TestTable的表。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章