Solved

MS SQL database deployment for VB/C# installation

Posted on 2004-09-21
3
234 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Excel object stays open 19 65
count8 challlenge 13 87
countPairs challenge 7 58
Controlled Assessment GCSE - desperate help needed 4 55
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This is about my first experience with programming Arduino.
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now