0
votes

I am using Installshield 2015 version.We have created a install script .msi project.

Under SQL Scripts Tab, we have created new SQL Connection.

I am providing CatalogName "NMC" and selected checkbox(Create catalog if absent).

I am running the below SQL Scripts to run against this Database(NMC).

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Account]') AND type in (N'U'))
BEGIN
    PRINT 'Tables have already been created'
END
ELSE
BEGIN

/****** Object:  Table [dbo].[Rights]    ******/
CREATE TABLE [dbo].[Rights](
    [RightId] [int] NOT NULL,
    [Name] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_Rights] PRIMARY KEY CLUSTERED 
(
    [RightId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

I want the Table created on the Database which is mentioned in Catalog(NMC).

Right now the script is executing against Master Database.

How can I execute the script against Catalog mentioned above?I don't want to use command "USE NMC" in SQL Script.

1
You can also specify the database when connecting. It's part of a standard connection string Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword; - Andomar
I am specifying the Catalog name(database name "NMC") in SQL Scripts tab under Server Configuration tab using Installshield 2015 - AMDI

1 Answers

0
votes

You may change default database MNC for login you use in top part & again change to master at the end...

Exec sp_defaultdb @loginame='login', @defdb='MNC'


Exec sp_defaultdb @loginame='login', @defdb='master'