SQL Comparison SDK
Latest version: 10.0
Knowledge Base
Creating a synchronization script without batch markers
Category: How do I?
Date: 03 Feb 2011
Product: SQL Comparison SDK
When saving a synchronization script produced by SQL Comparison SDK, you may want to save the script for later use by the ADO .NET client (SqlCommand). Since the script produced using SQL Toolkit's BlockSaver class in meant for SQL Server Management Studio, it includes batch separators (GO commands) that aren't understood by ADO .NET and will cause errors when run for this reason.
It is possible to save the SQL Toolkit ExecutionBlock in a way where batch markers are not included in the script by looping through the individual batches and saving only batches that are not marked as a batch marker. Here is an example code snippet which assumes that you have already populated an ExecutionBlock called "block":
- [C#]
- using (System.IO.StreamWriter sw=new System.IO.StreamWriter(@"c:\temp\test.sql"))
- {
- for (int i = 0; i < block.batchcount;="">
- {
- Batch b = block.GetBatch(i);
- if (b.Marker == false)
- {
- sw.Write(b.Contents + "\r\n");
- }
- }
- }
- [/C#]
Please note that you may want to use the NoSqlPlumbing option as well when you create the ExecutiuonBlock to prevent transactional operations from appearing in the script. ADO .NET has its' own methods for rolling back and committing transactions if necessary.
work.BuildFromDifferences(stagingVsProduction, Options.Default | Options.NoSQLPlumbing, true);
Document ID: KB200806000271 Keywords: SQL,SDK,batch,GO
Was this article helpful?
SQL Comparison SDK
- Licenses.licx is not a valid Win32 application
- Application licensing invalidated by renaming assembly
- Excluding a table from a data comparison
- Manually licensing Red Gate assemblies
- RedGate.Licensing.Helper.dll is attempting managed execution inside OS Loader lock
- Troubleshooting SQL Comparison SDK licensing
- SQL Compare synchronization error 'Full-Text Search is not installed'
- Using SQL Data Compare mappings in projects using the API
- Licensing automated builds with NAnt
- Licensing ASP .NET applications
- Running SQL code inside SQL Comparison SDK applications
- Creating an HTML report of schema differences in C#
- Creating a synchronization script without batch markers
- Creating an HTML report of schema differences in Visual Basic .NET
- SQL Toolkit has become SQL Comparison SDK
- SQL Comparison SDK column mapping
- Executing your own SQL queries together with SDK synchronization
- Error 1603 occurring during installation
- Licensing SDK applications in Visual Studio 2010
all SQL products
- Compatibility of Red Gate tools in 64-bit environments
- Application has encountered an error and needs to close
- Error message after installing SQL Toolbelt - The description for Event ID ( 1 ) in Source ( nview_info ) cannot be found.
- Changing the temporary directory used by the installer
- Toolbelt Installer "hanging" while "scanning volumes"
- Login failing with "trusted SQL Server connection" error when using RunAs
all products
- Some Red Gate products identified as containing a trojan by Anti-Virus software
- Activation may fail with Unknown Error -1
- Product uses web help although a CHM file is available locally
- Argument exception resulting from missing environment variable
- Check for updates may fail when used through proxies
- 'Unidentified Publisher' error when repairing or uninstalling
- Licensing activates product as standard edition
- Moving Red Gate software products to another machine
- Red Gate tools log locations
- The application UI opening slowly when there is no internet access
SQL Comparison SDK
all SQL products
all products
- Red Gate product acknowledgements
- Activating your products
- Activating your products
- Red Gate bundle history
- Check for updates
- Troubleshooting Check for Updates errors
- Current versions
- Deactivating your products
- Installing Red Gate products from the .msi file
- Requesting additional activations
- Serial numbers for bundles
- Reactivating using a different serial number
- Extending your trial
- Finding your serial numbers
- Moving a serial number from one computer to another
- No response received for manual activation
- Licensing and activation resources
- Licensing and activation resources
- Troubleshooting licensing and activation errors
- Licensing and activation FAQs
- Red Gate tools log file locations
- Download old versions of products
- Download product prerequisites & utilities
- Support & upgrades
- Upgrading your software
- Upgrading FAQs

Licensing and distribution