Solutions Products Download Purchase Support News Members Company
SITE FEED
Support Forum
The fastest and most effective to get answers to your questions quickly.
FAQs
Quick answers to common questions.
Troubleshooting
Known issues and basic troubleshooting techniques for problems or unexpected behaviors.
Knowledgebase
Technical tips, How-to articles, and other tutorials about ApexSQL Tools.
Online Documentation
All of our help files for download or convenient viewing online.
Videos
Watch product demos, training videos, or tutorials of our products' main features. 

ApexSQL Knowledgebase

Tips and How-to Articles for Apex SQL Tools


How to use ApexSQL Script C# solutions to execute ApexSQL Diff synchronization scripts

DESCRIPTION
This article describes how to use ApexSQL Script C# solutions for execution ApexSQL Diff synchronization scripts that will update your database: once compiled you can use the gotten .Net package to update client databases on different machines

SOLUTION

Before creating a .Net Package that will apply your changes to a database you need a C# solution. To obtain such a solution you can choose among two options:
- Download the ready solution from here. Then you can skip the step 1) below
- Use ApexSQL Script to create it: then please proceed with the step 1)

1) For the result C# solution created by ApexSQL Script you need at least one SQL Server 2000, 2005 or 2008 available at your network. Then you can use any database (for example, AdventureWorks or master database) to manually create a stub solution as follows:

a) Start ApexSQL Script and select any object(s) from any database to script: select a database at the right hand Select Database panel and select an object or objects in the main grid:



b) Run the Script Wizard and select C# Project as Output type:



c) Click the Create button and select the directory where your project will be created:



After the step is passed the stub C# project is created and is ready to use for the next step.

2) If you have already had a ready synchronization script: please skip this step. Otherwise use ApexSQL Diff.

a) Start ApexSQL Diff and select necessary databases for synchronization:



b) Using the Project Settings Wizard define necessary comparison options and object filters

c) Click the Compare button

d) Select the necessary objects to synchronize in the main grid and click the Synchronize tool button to start the Synchronization Wizard



e) In the Synchronization Wizard define all necessary options and then select the Write Script To File Only option at the Output Options Step. Define the directory where your script will be saved. You can save your file in the directory containing C# project made at the previous step:



f) Click the Synchronization button and your script will be created and saved at the chosen folder

3) At this step you should have a stub C# project and a synchronization script you want to apply to your database. To build the .Net package with the synchronization script please proceed with the next steps:

a) Open the directory where your C# project is saved. Enter to the directory with your Project name (in the example it is LOCAL@SQL2005.Aworks2005 Installer). Find the file with the *.dat extension. Actually it is a SQL script with objects scripted from the 1) step that can be deleted without a problem. Then find the synchronization script (file with *.sql extension – in the example “Synchronization.sql”)



and rename it to “LOCAL@SQL2005.Aworks2005 Installer.dat”.

b) Return back to the main project directory and start the *.sln file. Then Microsoft Visual Studio with this C# project will be opened

Now to create a .Net package just build the solution and then it will be ready to use on your environment.

AUTHOR
Andrew Guselnikov

LAST REVIEW DATE
11 June 2008

Labels: ,



© 2010 Apex SQL Tools All Rights Reserved | 1.919.968.8444 | Contact Us | Terms of Use | Privacy Policy