How to use bitwise set in ApexSQL CLI

Applies to
ApexSQL Clean, ApexSQL Diff, ApexSQL Diff for MySQL, ApexSQL Doc, ApexSQL Script

Summary
This article explains how to use the bitwise set switch in the CLI of ApexSQL tools.

Description

ApexSQL Doc
After connecting to SQL Server, and selecting the database, you may choose a combination of objects, and the appropriate bitwise set will be automatically generated. From the Data sources and objects pane under the Database engine, click the Server objects option, and the bitwise set will be generated for the selected combination of the server objects, like shown in the image below:

Bitwise set is generated for the selected combination of the server objects

To include the selected objects in the database documenting process, add the “/so:” switch in the CLI command, followed by the bitwise set for the selection, as shown below:

ApexSQLDoc /dbes:AdventureWorks2014 /od:D:\Test\Documentation /so:32 /v /f

For the database objects, in the Data sources and objects pane under the Database engine tab, select the Database objects tab. For the selected objects the bitwise set will be automatically created at the bottom of the window, like shown below:

Adding the “/so:” switch in the CLI command, followed by the bitwise set for the selection

To use the generated bitwise set based on the selected objects, add the“/o:” switch (without quotations marks) along with the bitwise set number that represents a combination of the selected objects in the CLI command, as shown in the example below:

ApexSQLDoc /dbes:AdventureWorks2014 /od:D:\Test\Documentation /o:26422370103805 /v /f

ApexSQL Clean, ApexSQL Diff, ApexSQL Diff for MySQL, ApexSQL Script
After connecting to the Server, and selecting the database for processing, from the New project window, expand the Advanced options tab, and choose the Object filter tab, as shown in the image below:

Choosing the Object filter tab

In the Object filter tab, you may choose the appropriate combination of the objects that will be processed. For each combination of the selected object, the bitwise set will be generated. To use it in CLI, add a switch “/include:” (without quotation marks) and the bitwise set that represents the object selection, as shown in the example below:

ApexSQLDiff /d1:AdventureWorks2014 /d2:AdventureWorks2016 /include:4780317 /v /f

Top FAQs about a bitwise set

  • Q: Why is the bitwise set used?

    A: Bitwise set is used for practical reasons to avoid unnecessary use of the include switch of ApexSQL applications in the CLI if there is more than one object type that will be used in the command line.

    For example, if the following object types: Tables, Data types, and Users were to be used in the CLI using the include switch they would have to be entered as “/include:8 /include:4096 /include:8192”, where the number 8 represents Tables, number 4096 represents Data types and number 8192 represents Users. When all three object types are selected in the GUI they will produce bitwise set number 12296, and when that number is used with the switch “/o:” it will include all three object types listed above. So, “/o:12296” would act the same as the “/include:8 /include:4096 /include:8192”.

  • Q: Is the bitwise set number unique?

    A: For each selection of object types from the GUI the specific bitwise set number is generated which represents that selection.

  • Q: Can the same bitwise set number be used in all ApexSQL applications?

    A: That depends on which types they are generated and if the application supports bitwise set use. For example, in ApexSQL Doc we have two switches used in the CLI “/so:” for server objects and “/o:” for database objects since in ApexSQL Doc bitwise set number 4 represents Credentials in server objects and the same number 4 represents Views in database objects. So, if the objects for which the bitwise set number is generated are from the same group, then their bitwise set number can be used in other ApexSQL applications, that support the bitwise set, using the appropriate switch.