473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Installing, creating database, updating schema?


Hi there,

I have a database on my test machine that will need to be installed on users
machines. I would like to create the database with the given schema on the
users machine and also with some suitable default values in the tables. I
note that although I can script the schema so that re-creating the structure
of the database is simple on the users machine, I cannot script the contents
of the tables also (automatically). What I would like to do is take some
kind of "snapshot", save it as a script and then run this script in my
installer. Are there any tools available to do this?

Secondly and related to the above: if I subsequently make changes to the
database schema (adding or removing columns, altering, adding or removing
stored procedures etc.), how do I roll out those changes to a customer? Do
I need to hand code an "upgrade" script, or is there a tool that will
produce a "difference between" script I can run on the customers machine?

Thanks for any tips you can give me about this.


Robin
Jul 20 '05 #1
3 2759
Robin Tucker (id*************************@reallyidont.com) writes:
I have a database on my test machine that will need to be installed on
users machines. I would like to create the database with the given
schema on the users machine and also with some suitable default values
in the tables. I note that although I can script the schema so that
re-creating the structure of the database is simple on the users
machine, I cannot script the contents of the tables also
(automatically). What I would like to do is take some kind of
"snapshot", save it as a script and then run this script in my
installer. Are there any tools available to do this?
SQL Server MVP Vyas Kondreddi has a tool that generates INSERT statements
from a table: http://vyaskn.tripod.com/code.htm#inserts
Secondly and related to the above: if I subsequently make changes to the
database schema (adding or removing columns, altering, adding or
removing stored procedures etc.), how do I roll out those changes to a
customer? Do I need to hand code an "upgrade" script, or is there a
tool that will produce a "difference between" script I can run on the
customers machine?


There are several paths to take. Many people use a third-party tool that
compares two databases and then generates a script. Very popular is
SQL Compare from Red Gate. I have not used this tool myself, though.

A better approach in my opinion, is to have all code under source control.
In this case, your development database is not your master, but the
version-control system is. A basic version-control system will not
provide any update scripts for you, as a version-control system is a
general container for all sorts of code. What you do is that when you
ship, you set a label, and then you can later inquire the VCS for
changes since that label. There are plenty of VCS on the market. Very
popular among Microsoft customers is Visual SourceSafe which is part
of Visual Studio. VSS is not a very good for serious configuraton
management, but it's easy to get started with, and works perfectly OK for
smaller groups.

There are a couple of third-party tools that are specialized for doing
version control on SQL Server. Typically, they sit on top of SourceSafe
or some other generic VCS. Unfortunately, I don't recall any names right
now.

In our shop we use VSS, together with a toolset that includes tools for
loading stored procedures (with a lot of bells and whistles, like
automatic insert of SET NOCOUNT ON, WITH ENCRYPTION (on request),
automatic GRANT, a preprocessor). We also have a tool that builds
update scripts from the checkins in SourceSafe. The tool also maintains
its own tables in the target databases, so that we know in which state
each database is in. This toolset is available as freeware on
http://www.abaris.se/abaperls/. (I uploaded the latest version of it,
just the other day, by the way.)

Judging from your question, you may be best off with something like
SQL Compare in the short run. But if more people get involved with
your work, you should definitely consider to move to a version-
control system. There are a few things to keep in mind with updating
from a model database:

o A development may contain junk code and junk tables from tests and
experiments.
o A table change may be as simple as adding a nullable column, but it
can also be very complex if you are making a major restructiring. A
tool probably needs some help in this case.
o If you have preloaded data that you want to deploy, you need a tool
where you selectively can migrate data.

The way we handle pre-loaded data by the way, is to enter the data in
Excel books, and then we have a tool that generates INSERT files from
the the Excel files. The files does not contain any INSERT statements,
but calls to stored procedures which inserts or updates. The reason we
use Excel is that some of our files are quite complex. and we have
different settings for different customers.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
Very interesting. Thanks for your comprehensive reply. I think I will need
to study this question at some length before deciding which approach to
take.

Robin

"Erland Sommarskog" <es****@sommarskog.se> wrote in message
news:Xn**********************@127.0.0.1...
Robin Tucker (id*************************@reallyidont.com) writes:
I have a database on my test machine that will need to be installed on
users machines. I would like to create the database with the given
schema on the users machine and also with some suitable default values
in the tables. I note that although I can script the schema so that
re-creating the structure of the database is simple on the users
machine, I cannot script the contents of the tables also
(automatically). What I would like to do is take some kind of
"snapshot", save it as a script and then run this script in my
installer. Are there any tools available to do this?


SQL Server MVP Vyas Kondreddi has a tool that generates INSERT statements
from a table: http://vyaskn.tripod.com/code.htm#inserts
Secondly and related to the above: if I subsequently make changes to the
database schema (adding or removing columns, altering, adding or
removing stored procedures etc.), how do I roll out those changes to a
customer? Do I need to hand code an "upgrade" script, or is there a
tool that will produce a "difference between" script I can run on the
customers machine?


There are several paths to take. Many people use a third-party tool that
compares two databases and then generates a script. Very popular is
SQL Compare from Red Gate. I have not used this tool myself, though.

A better approach in my opinion, is to have all code under source control.
In this case, your development database is not your master, but the
version-control system is. A basic version-control system will not
provide any update scripts for you, as a version-control system is a
general container for all sorts of code. What you do is that when you
ship, you set a label, and then you can later inquire the VCS for
changes since that label. There are plenty of VCS on the market. Very
popular among Microsoft customers is Visual SourceSafe which is part
of Visual Studio. VSS is not a very good for serious configuraton
management, but it's easy to get started with, and works perfectly OK for
smaller groups.

There are a couple of third-party tools that are specialized for doing
version control on SQL Server. Typically, they sit on top of SourceSafe
or some other generic VCS. Unfortunately, I don't recall any names right
now.

In our shop we use VSS, together with a toolset that includes tools for
loading stored procedures (with a lot of bells and whistles, like
automatic insert of SET NOCOUNT ON, WITH ENCRYPTION (on request),
automatic GRANT, a preprocessor). We also have a tool that builds
update scripts from the checkins in SourceSafe. The tool also maintains
its own tables in the target databases, so that we know in which state
each database is in. This toolset is available as freeware on
http://www.abaris.se/abaperls/. (I uploaded the latest version of it,
just the other day, by the way.)

Judging from your question, you may be best off with something like
SQL Compare in the short run. But if more people get involved with
your work, you should definitely consider to move to a version-
control system. There are a few things to keep in mind with updating
from a model database:

o A development may contain junk code and junk tables from tests and
experiments.
o A table change may be as simple as adding a nullable column, but it
can also be very complex if you are making a major restructiring. A
tool probably needs some help in this case.
o If you have preloaded data that you want to deploy, you need a tool
where you selectively can migrate data.

The way we handle pre-loaded data by the way, is to enter the data in
Excel books, and then we have a tool that generates INSERT files from
the the Excel files. The files does not contain any INSERT statements,
but calls to stored procedures which inserts or updates. The reason we
use Excel is that some of our files are quite complex. and we have
different settings for different customers.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Jul 20 '05 #3
I would recommend you have a look at Innovartis DB Ghost at
http://www.innovartis.co.uk/ It is designed specifically for your
requirement i.e. automated database change management, generation of
upgrade scripts, build verification, database synchronization,
deployment of changes, integration with version control system, handles
schema & data.

John McGrath
SQL Server DBA MCSE

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John | last post by:
I'm developing an application for medical use that will be used to capture patient background and visit data. The application will have approximately 50 forms, with an average of about 20 fields...
6
by: Dim St Thomas | last post by:
I am a developer working on a database client program. I am testing this program on a Windows XP machine (1.5 GHz AMD chip, 480 Mb RAM, 60 Gb disk) This machine has Oracle 9.2.0.1.0 and RedBrick...
4
by: pshindle | last post by:
DB2 Team - I just downloaded and unzipped the new Fixpack 9 for DB2 ESE V8 for Windows (FP9_WR21350_ESE.exe). I then burned the unzipped Fixpack files to a CD. I proceded to install this...
3
by: Kiran | last post by:
Hi, I want to back up my data in some table in SQL server and import it back using Bulk Load of SQL server 2K. I can use the following code to backup the data in XML ...
3
by: Sindarian | last post by:
I have a Schema from the folk that shows how they want the data received. I have my own database that has that data, but in a different way (they use 33 freaking tables to store what I do in 1)....
4
by: RS | last post by:
Hello All, Does anyone know what the best practice is for updating database schema? We are designing a smart client application where the .Net application is used online and offline. If the...
2
by: Adam Witney | last post by:
Forwarding to the mailing list, as I don't know how to fix it.... ------ Forwarded Message From: Henning Klein <kleinh@rz.uni-potsdam.de> Date: Tue, 22 Jun 2004 22:09:08 +0200 To:...
0
by: Johnny | last post by:
I have a PocketPC mobile application that gets its data from the Sql Server database via a web service. The web service returns a dataset that I need to load into the SqlCe database on the mobile...
1
by: vijaykumars | last post by:
+-----------------------------------------------------------------------------+ Summaries: +-----------------------------------------------------------------------------+ Installation...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.