Sunday, January 31, 2021

Synchronize database schemas - SQL Compare SDK

Comparing and synchronizing the schemas of two SQL Server databases is very easy with xSQL Software's SQL Schema Compare SDK. As you can see in the code snippet in the image below, there are only 5 simple steps involved in making the schema of database A the same as the schema of database B: 

  1. Read the schemas of both databases
  2. Pair objects based on the object name
  3. Compare the paired objects to each other
  4. Generate the synchronization script
  5. Execute the script on the target
Of course, as we have mentioned in other articles, SQL Compare SDK gives you complete control over the database compare operation allowing you to:
  1. exclude or include certain types of objects - for example, if you do not want to compare database users you can do comparer.Options.CompareUsers = false
  2. create entity filters to exclude for example only stored procedures the name of which starts with sp_PS
  3. exclude / include specific objects, for example don't compare table "employees"
  4. set comparison options and scripting options based on your specific requirements 
  5. set execution options such as transaction size, whether to continue execution on error etc. 

Download the SQL Schema Compare SDK and check out the extensive documentation - you will be able to build your first database comparison and synchronization application in no time. 

0 comments:

Post a Comment