Solved

MS SQL database deployment for VB/C# installation

Posted on 2004-09-21
3
258 Views
Last Modified: 2010-04-17
I have a sql database that is used by my application.
How do I setup a deployment project so that the SQL db is automatically generated and can be used (assuming that MSDE or SQL 2000 is installed)?
If I have to generate a sql script for this installation, how do I make sure that not only the tables, and views ( and stored procedures) are scripted, but also the data inside the DB? (ie. SQL statements such as Insert into TABLE .... also included).
Thank you in advance for replies
0
Comment
Question by:Bjorn_Holdt
  • 2
3 Comments
 
LVL 3

Expert Comment

by:mAjKoL
ID: 12111642
Use the Enterprise Manager and "Generate SQL Script" option. You'll find many options there.
Then jou can just create the db from within your code,

HTH
0
 
LVL 3

Accepted Solution

by:
Validor earned 125 total points
ID: 12117838
Scripts will create the database, but it will be empty.  If you want the data too, the fastest way to do this is to ATTACH the database to the server.  The only time-consuming aspect of this is copying the database file to the disk from the installer.  There is no transformation or insertion necessary.  It's already a valid, complete MSSQL database.  You effectively just "turn it on" by telling SQL Server where the file is.  

This web site covers this with examples.

http://www.databasejournal.com/features/mssql/article.php/1439831


If you're working with MSSQL 6.5 or lower, you cannot attach a database.  You may have to export the data with BCP and then reimport it with BCP or a bulk-insert.  That's still really fast, but not as fast as attaching a database, because it involves transformation.  It also doesn't include users, roles, statistics, indexes, etc.  You'd have to create all of these manually.

If the data is not too large, it might be okay to use DTS to export the MSSQL data to an access database.   Include the access database in your deployment, then use another DTS package to import the Access database into the target MSSQL server.  This is also a transformation, but it's generally very fast.  
0
 
LVL 3

Expert Comment

by:mAjKoL
ID: 12117928
This might be a little more helpful:
"Writing Your Own Script File to Migrate a Database"
http://www.15seconds.com/issue/011106.htm

This should do the trick :)

HTH
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question