MS SQL Server
  Home arrow MS SQL Server arrow Page 7 - Source Code Management and Database Deploy...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MS SQL SERVER

Source Code Management and Database Deployment
By: McGraw-Hill/Osborne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 15
    2005-06-16

    Table of Contents:
  • Source Code Management and Database Deployment
  • Administering the Visual SourceSafe Database
  • Managing Create Scripts in Visual Studio .NET
  • Visual SourceSafe Explorer
  • Labels and Versions
  • Database Deployment
  • Deployment of Individual Objects
  • Scripting Data in Visual Studio .NET
  • Deploying Create Scripts in Visual Studio .NET

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Source Code Management and Database Deployment - Deployment of Individual Objects


    (Page 7 of 9 )

    Some organizations choose to manage the code for individual objects and to deploy the database piecemeal by executing the code on the production server. This provides more flexibility, but requires more effort.

    Deployment Scripts: Traditional Approach

    Individual object scripts can be grouped in files with all objects of a particular type or even with all objects in a database. Such files can be created using the Generate SQL Script tool in Enterprise Manager. It can be set so that the group of objects of the same type is saved in a single file. It is also possible to use a custom tool to aggregate individual database object files from the Visual SourceSafe database. Most ERD modeling tools can also produce such scripts (but their scripts often require manual intervention). You can also use TbDbScript, described earlier in this chapter.

    To have better control, I like to use the TbDbScript tool, or the Generate SQL Script tool in SQL Server, to create one deployment script for each type of database object. When the system contains more than one database, I find it very useful that TbDbScript names deployment script files using the Database - DbObjectType.sql convention (see Figure 11-7).

    Scripting Data: Traditional Approach

    Some tables contain data (seed, static, or lookup data) that needs to be deployed along with the database schema. To assist in deployment and to facilitate storing the data with the source code, use the setup_DataGenerator stored procedure, described in Chapter 9.

    Use the setup_DataGenerator procedure on all tables with data that need to be scripted:

    set nocount on
    exec setup_DataGenerator 'AcquisitionType'
    exec setup_DataGenerator 'EqType'
    exec setup_DataGenerator 'Location'
    exec setup_DataGenerator 'OrderStatus'
    exec setup_DataGenerator 'OrderType'
    exec setup_DataGenerator 'Status'
    exec setup_DataGenerator 'Province'


    Figure 11-7.  Deployment scripts

    The result will be a script that consists of Insert statements (which had to be cropped to fit the page):

    -----------------------------------------------------------
    Insert into AcquisitionType (AcquisitionTypeId,AcquisitionType) values
    Insert into AcquisitionType(AcquisitionTypeId,AcquisitionType) values
    Insert into AcquisitionType(AcquisitionTypeId,AcquisitionType) values
    Insert into AcquisitionType(AcquisitionTypeId,AcquisitionType) values
    Insert into AcquisitionType(AcquisitionTypeId,AcquisitionType) values

    -----------------------------------------------------------
    Insert into EqType(EqTypeId,EqType) values (1,'Desktop') Insert into EqType(EqTypeId,EqType) values (2,'Notebook') Insert into EqType(EqTypeId,EqType) values (3,'Monitor') Insert into EqType(EqTypeId,EqType) values (4,'Ink Jet Printer')
    ...

    Save the resulting scripts in a text file (I often use Database - Data.sql as the name of this file).

    More MS SQL Server Articles
    More By McGraw-Hill/Osborne


     

    Buy this book now. This article is excerpted from SQL Server 2000 Stored Procedure & XML Programming, second edition, written by Dejan Sunderic (McGraw-Hill/Osborne, 2004; ISBN: 0072228962). Check it out at your favorite bookstore today. Buy this book now.

    MS SQL SERVER ARTICLES

    - Windows Server 2008 as a Workstation OS
    - An Overview of Windows Server 2008 R2
    - LINQ to MySQL, Oracle and PostgreSQL Provide...
    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek