Transactions

si_hesi_he Posts: 25
edited September 5, 2007 5:16AM in SQL Toolkit Previous Versions
You have the option to omit the use of transactions in the SQL script via the "Synchronisation behavior" options tab in the gui.

How do you do this using the API?

I can output the SQL statements required but I don't want them executed as part of a transaction.

Many thanks

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi,

    Wherever an 'Options' enumeration is used, specify the NoSQLPlumbing option as part of the enumeration.
    Options o=Options.NoSQLPlumbing | Options.Default;
    Work w=new Work();
    w.BuildFromDifferences(Diffs,o,true);
    ...
    
  • OK I'm using VB and I have done a simple compare session on one table and outputted the required SQL via the console using the following code:

    Dim provider As New SqlProvider
    Dim block As ExecutionBlock = provider.GetMigrationSQL(session, True)
    Console.WriteLine("Migration SQL:")
    Console.WriteLine(block.GetString())

    Where should the NoSQLPlumbing come into this?

    Sorry for my ignorance :wink:
  • Sorry, the previous instructions were for the SQL Compare side of the toolkit. For Data Compare, which is what you're using:

    First create an EngineDataCompareOptions object.

    Set its SqlOptions property to some combination of the options on http://help.red-gate.com/help/SQLDataCo ... tions.html not including the UseTransactions option. (Unfortunately as the default set of options contains this option you'll have to set the other options manually rather than just choosing the defaults.) You can link options together with a | to choose several options.

    Then you can set the Options property of the SqlProvider object to the newly created EngineDataCompareOptions object.

    You should do this before calling getMigrationSQL.

    Does that help or should I put together a code example?
    Software Developer
    Redgate Software
  • OK I think I see what you're saying, could I ask you to post a code example? :wink:

    Thanks
  • OK I have it owrking like this -

    Dim o As New EngineDataCompareOptions
    Dim provider As New SqlProvider
    provider.Options.SqlOptions = SqlOptions.None
    Dim block As ExecutionBlock = provider.GetMigrationSQL(session, True)
    Console.WriteLine("Migration SQL:")
    Console.WriteLine(block.GetString())

    Thanks
Sign In or Register to comment.