---
title: "Finish upgrading the Collection databases"
slug: "finish-upgrading-the-collection-databases"
abstract: ""
---
# Finish upgrading the Collection databases

> [!important]
> This section only applies if you are upgrading from Sitecore XP 9.0.0 - 9.2.0.

We recommend that you perform this step to align the database schema with the changes that were introduced in Sitecore XP 9.3.0.

You must perform the tasks described in this section if you are using SQL Azure and planning to use the split/merge tool.

In SQL Azure, the aligned schema lets you use the scale-out feature with the help of the Microsoft Split/Merge service. For more information, see the article Split or merge xDB Collection database shards.

1. Ensure that all the *\*_Staging* tables are empty.
2. If the tables are not empty, delete all the data from the following tables:

    ```

    DELETE FROM [xdb_collection].[CheckContacts_Staging]
    DELETE FROM [xdb_collection].[ContactFacets_Staging]
    DELETE FROM [xdb_collection].[ContactIdentifiers_Staging]
    DELETE FROM [xdb_collection].[ContactIdentifiersIndex_Staging]
    DELETE FROM [xdb_collection].[Contacts_Staging]
    DELETE FROM [xdb_collection].[DeviceProfileFacets_Staging]
    DELETE FROM [xdb_collection].[DeviceProfileFacets_Staging]
    DELETE FROM [xdb_collection].[GetContactIdsByIdentifiers_Staging]
    DELETE FROM [xdb_collection].[GetContactsByIdentifiers_Staging]
    DELETE FROM [xdb_collection].[InteractionFacets_Staging]
    DELETE FROM [xdb_collection].[Interactions_Staging]
    DELETE FROM [xdb_collection].[UnlockContactIdentifiersIndex_Staging]
    ```

3. To generate the shard keys for data rebalancing and/or missed percentile values, run the *Sitecore Xdb Collection Update* tool.

    For more information, see, [Generating shard keys and missing percentile values](https://doc.sitecore.com/xp/en/developers/105/guides/upgrade-guide-for-sitecore-experience-platform-1050/appendix-b---generating-shard-keys-and-missing-percentile-values.html "Appendix B – Generating shard keys and missing percentile values").

4. After you have run the *Sitecore Xdb Collection Update* tool:

    If *Always Encrypted* (AE) is On:

    - Run the `SXP_collection_AE_Part2.sql` script for every shard.

    If AE is Off:

    - Run the `SXP_collection_Part2.sql` script for every shard.