Unix Technical Forum

Server install script

This is a discussion on Server install script within the SQL Server forums, part of the Microsoft SQL Server category; --> This one is stumping me.. please help. I put together a DB with lots of tables, sprocs, etc.. Now ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 06:43 PM
Ty
 
Posts: n/a
Default Server install script

This one is stumping me.. please help.

I put together a DB with lots of tables, sprocs, etc..

Now I want to wrap it up into one nice little .SQL which will generate
everything for a user. To that end, I went into Enterprise Manager, and
selected "Generate SQL script".

All is well until someone wants to execute it on a machine where SQL is not
installed in the same DIR where I have SQL installed. So.. how do I generate
a CREATE script which is smart enough to create the DB in the same physical
path where SQL is installed for that particular user?

Have I lost you yet? Here is a snippet of the DDL:

<paste>

IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'MyNewDB')

DROP DATABASE [MyNewDB]

GO

CREATE DATABASE [MyNewDB] ON (NAME = N' MyNewDB _Data', FILENAME =
N'C:\Program Files\Microsoft SQL Server\MSSQL\data\ MyNewDB_Data.MDF' , SIZE
= 34, FILEGROWTH = 10%) LOG ON (NAME = N' MyNewDB_Log', FILENAME =
N'C:\Program Files\Microsoft SQL Server\MSSQL\data\ MyNewDB.LDF' , SIZE =
344, FILEGROWTH = 10%)

COLLATE SQL_Latin1_General_CP1_CI_AS

GO

</paste>

OK.. how do I make the areas in BOLD write to <%SQLSERVERINSTALLPATH%>, or
something like that?

Thanks!

/Ty


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 06:44 PM
John Bell
 
Posts: n/a
Default Re: Server install script

Hi

Using create database with no on clause will create a mdf and ldf in the
default locations. This is not necessarily where the SQL Server program was
installed, and is probably the better location.

You can then use sp_helpfile to find out the actual locations if you want to
add new files, or use
ALTER DATABASE to change the files there were created.


CREATE DATABASE Test2
USE TEST2
sp_helpfile

ALTER DATABSE Test2
MODIFY FILE (NAME=Test2, SIZE=34MB, FILEGROWTH=10MB )

Also I would always fix the FILEGROWTH to a value in MBs as the growth will
be exponential if left as a percentage.

Your initial size of the log file seems excessive especially when compared
to the initial size of the data file.

John

"Ty" <tybala on the server at hotmail.com> wrote in message
news:534011cb132551610c6bd5294e743b99@news.teranew s.com...
> This one is stumping me.. please help.
>
> I put together a DB with lots of tables, sprocs, etc..
>
> Now I want to wrap it up into one nice little .SQL which will generate
> everything for a user. To that end, I went into Enterprise Manager, and
> selected "Generate SQL script".
>
> All is well until someone wants to execute it on a machine where SQL is

not
> installed in the same DIR where I have SQL installed. So.. how do I

generate
> a CREATE script which is smart enough to create the DB in the same

physical
> path where SQL is installed for that particular user?
>
> Have I lost you yet? Here is a snippet of the DDL:
>
> <paste>
>
> IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name =

N'MyNewDB')
>
> DROP DATABASE [MyNewDB]
>
> GO
>
> CREATE DATABASE [MyNewDB] ON (NAME = N' MyNewDB _Data', FILENAME =
> N'C:\Program Files\Microsoft SQL Server\MSSQL\data\ MyNewDB_Data.MDF' ,

SIZE
> = 34, FILEGROWTH = 10%) LOG ON (NAME = N' MyNewDB_Log', FILENAME =
> N'C:\Program Files\Microsoft SQL Server\MSSQL\data\ MyNewDB.LDF' , SIZE =
> 344, FILEGROWTH = 10%)
>
> COLLATE SQL_Latin1_General_CP1_CI_AS
>
> GO
>
> </paste>
>
> OK.. how do I make the areas in BOLD write to <%SQLSERVERINSTALLPATH%>, or
> something like that?
>
> Thanks!
>
> /Ty
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:12 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com