How can I stop SDC from adding comments to sql script?
RBohannon
Posts: 25
Each night, our application uses the SQL Data Compare API to create a syncronization SQL script which is then sent from the client site to our home office.
We are trying to minimize the file size of these SQL scripts for our clients so we would like to prevent SQL Data Compare from adding any comments to the script. Is there a built-in way to do this?
Thank you.
We are trying to minimize the file size of these SQL scripts for our clients so we would like to prevent SQL Data Compare from adding any comments to the script. Is there a built-in way to do this?
Thank you.
Comments
You can achieve this by setting the TableMappings.Options in the following manner:
You can see how I'm using the above code in the following program
Hope this helps
Chris
Test Engineer
Red Gate
Dim mappings As New TableMappings
mappings.Options.SqlOptions = SqlOptions.OutputComments Xor SqlOptions.OutputCommentHeader Xor SqlOptions.Default
Correct?
Thank you.
Interestingly when I disassembled my test assembly with Reflector and chose to display it as VB I got the following -
...maybe my code was optimised by the compiler when I generated the assembly but it seems to use the logical Or rather than Xor. Personally I'd try the Xor first as this seems to work for me in c#.
Regards
Chris
Test Engineer
Red Gate
The Visual Basic language doesn't discriminate between a logical and a bitwise OR, in either case, the VB operator is simply Or and the VB compiler is meant to determine whether to use logical or bitwise depending on the operation.
mappings.Options.SqlOptions = SqlOptions.OutputComments Xor SqlOptions.UseTransactions Xor SqlOptions.OutputCommentHeader Xor SqlOptions.Default
This is equivalent to
mappings.Options.SqlOptions = SqlOptions.DisableKeys
because DisableKeys is the only default setting I'm not turning off. I confirmed in the watch window that my xor string is being evaluated to just "DisableKeys". But the program seems to be ignoring the SqlOptions altogether and inserting all the comments and transaction statements.
Any idea why the program is ignoring SqlOptions?
Thanks.
In my code example above there are some important assignments further down that ensure that the SqlOptions in TableMappings.Options are also used by the SQLProvider object.
It does it in 2 steps. Firstly: and then:
You might be able to get away with setting it directly e.g.
Whatever technique you choose, I suspect that the reason that you are getting comments still is that you need to set up the options for the SqlProvider object.
Test Engineer
Red Gate
I will make the change and let you know if that fixes it.
Regards
Chris
Test Engineer
Red Gate