?
Solved

MS SQL database deployment for VB/C# installation

Posted on 2004-09-21
3
Medium Priority
?
272 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 500 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

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 …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
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 …
Starting up a Project
Suggested Courses

800 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