Solved

MS SQL database deployment for VB/C# installation

Posted on 2004-09-21
3
270 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Introduction to Processes

726 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