ÓÃ×Ô¶¨ÒåµÄ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 SERVER ºÍACCESSµÄÊý¾Ýµ¼Èëµ¼³ö
³£¹æµÄÊý¾Ýµ¼Èëµ¼³ö£º
ʹÓÃDTSÏòµ¼Ç¨ÒÆÄãµÄAccessÊý¾Ýµ½SQL Server£¬Äã¿ÉÒÔʹÓÃÕâЩ²½Öè:
¡¡¡¡¡ð1ÔÚSQL SERVERÆóÒµ¹ÜÀíÆ÷ÖеÄTools£¨¹¤¾ß£©²Ëµ¥ÉÏ£¬Ñ¡ÔñData Transformation
¡¡¡¡¡ð2Services£¨Êý¾Ýת»»·þÎñ£©£¬È»ºóÑ¡Ôñ czdImport Dat ......
ÊìϤSQL SERVER 2000µÄÊý¾Ý¿â¹ÜÀíÔ±¶¼ÖªµÀ£¬ÆäDTS¿ÉÒÔ½øÐÐÊý¾ÝµÄµ¼Èëµ¼³ö£¬Æäʵ£¬ÎÒÃÇÒ²¿ÉÒÔʹÓÃTransact-SQLÓï¾ä½øÐе¼Èëµ¼³ö²Ù×÷¡£ÔÚTransact-SQLÓï¾äÖУ¬ÎÒÃÇÖ÷ҪʹÓÃOpenDataSourceº¯Êý¡¢OPENROWSET º¯Êý£¬¹ØÓÚº¯ÊýµÄÏêϸ˵Ã÷£¬Çë²Î¿¼SQLÁª»ú°ïÖú¡£ÀûÓÃÏÂÊö·½·¨£¬¿ÉÒÔÊ®·ÖÈÝÒ×µØʵÏÖSQL SERVER¡¢ACCESS¡¢EXCELÊý¾Ýת»»£ ......
--º¯ÊýÈçÏ£º
/*
CREATE FUNCTION dbo.fnpbGetPYFirstLetter
(
@str NVARCHAR(4000)
)
RETURNS NVARCHAR(4000)
--WITH ENCRYPTION
AS
BEGIN
DECLARE @WORD NCHAR(1),@PY NVARCHAR(4000)
SET @PY=''
WHILE LEN(@STR)>0
BEGIN
SET @WORD=LEF ......
IF EXISTS (SELECT name from master.dbo.sysdatabases WHERE name = N'MyDatabase')
DECLARE @backupdate varchar(255);
DECLARE @result int
DECLARE @result1 int
DECLARE @dbid uniqueidentifier
SET @dbid = NEWID()
EXEC @result = xp_cmdshell 'cd D:\SQLServerBackups';
IF (@result = 1)
EXEC @result1 = ......
ÒÔÏÂʵÏÖ¸´ÖƲ½Ö裨ÒÔ¿ìÕÕ¸´ÖÆΪÀý£©
ÔËÐÐƽ̨SQL SERVER 2005
Ò»¡¢×¼±¸¹¤×÷£º
1£®½¨Á¢Ò»¸ö WINDOWS Óû§£¬ÉèÖÃΪ¹ÜÀíԱȨÏÞ£¬²¢ÉèÖÃÃÜÂ룬×÷Ϊ·¢²¼¿ìÕÕÎļþµÄÓÐЧ·ÃÎÊÓû§¡£
2£®ÔÚSQL SERVERÏÂʵÏÖ·¢²¼·þÎñÆ÷ºÍ¶©ÔÄ·þÎñÆ÷µÄͨÐÅÕý³££¨¼´¿ÉÒÔ»¥·Ã£©¡£´ò¿ª1433¶Ë¿Ú£¬ÔÚ·À»ðǽÖÐÉèÌØÀý
3£®ÔÚ·¢²¼·þÎñÆ÷ÉϽ¨Á¢Ò»¸ö ......