Solved

MS SQL database deployment for VB/C# installation

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
If you don't know how to downgrade, my instructions below should be helpful.
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 …
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…

920 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

12 Experts available now in Live!

Get 1:1 Help Now