Search code examples
exportazure-sql-databaseazure-data-sync

Removing data sync meta data from Azure Sql database copy


I'm trying to export our production Azure SQL database to local for testing purposes. I've made a copy of the database but get the following error when trying to Export.

One or more unsupported elements were found in the schema used as part of a data package. Error SQL71501: Error validating element [dss]: Schema: [dss] has an unresolved reference to object [##MS_SyncAccount##]. Error SQL71501: Error validating element [TaskHosting]: Schema: [TaskHosting] has an unresolved reference to object [##MS_SyncAccount##].

I've found this article explaining how to get around this issue:

https://techcommunity.microsoft.com/t5/azure-database-support-blog/exporting-a-database-that-is-was-used-as-sql-data-sync-metadata/ba-p/369062.

My question is, will running the script below (from the article) on the copied database affect only the copy's data sync meta data, or is there a risk that it will affect our production database or server in any way?

Script: https://raw.githubusercontent.com/vitomaz-msft/DataSyncMetadataCleanup/master/Data%20Sync%20complete%20cleanup.sql

Many thanks


Solution

  • The script provided in the link will only clean up sync database objects, you can check the schema name mentioned in the where condition. If you want to be more sure you can just run the select statements and re-verify the objects against the main database.

    As an example, below statement would fetch stored procedures with specific schema name mentioned in the where clause.

    select @procedures = isnull( @procedures + @n, '' ) + 'drop procedure [' + schema_name(schema_id) + '].[' + name + ']'
    from sys.procedures
    where schema_name(schema_id) = 'dss' or schema_name(schema_id) = 'TaskHosting' or schema_name(schema_id) = 'DataSync'