cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
davidgid
Level 3

Specify Database File Location

I have look around and do not see an answer for this. I am using the database import wizard to create the db to be imported on my install. I need to be able to specify that the database .mdf and .ldf files be located in the same directory that my .dlls are being stored. How do I do that?
Labels (1)
0 Kudos
(3) Replies
Alpesh
Flexera Alumni

Hi,

You will have to use the Text Replacement tab in the Sql Scripts view. You can refer a unique text in the sql script with the [INSTALLDIR] property.

I hope this helps.

Thanks!
0 Kudos
davidgid
Level 3

I am not sure I understand. In my InstallScript project I have a connection. In that connection I have the check box called "Create Catalog If Absent" checked.

I want it to create that database in my c:\Program Files\My Application\ directory not under the instance folder created by SQLServer: C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008\MSSQL\DATA

So you are saying if I do a find and replace on the [INSTALLDIR] that it will move the database? It seems like once we have gotten to the first script the database will have already been created.
0 Kudos
hidenori
Level 17

The first thing that you need to do is to uncheck the Create Catalog If Absent option, and then you need to add a SQL script that will create a database and schedule to run duing login. If you want to specify that the database .mdf and .ldf files be located in the [INSTALLDIR] directory, you need to add the Text Replacement entry below in the SQL Scripts view, and the SQL script would be like this:

Find What: %InstallDir%
Replace With: [INSTALLDIR]

CREATE DATABASE TestDb
ON
( NAME = TestDb_dat,
FILENAME = '%InstallDir%testdbat.mdf',
SIZE = 10,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = TestDb_log,
FILENAME = '%InstallDir%testdblog.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB ) ;
GO
0 Kudos