Monday, April 18, 2022

Lesson Learned #198: Getting the error "has an unresolved reference to object " exporting to bacpac

When you are exporting a bacpac you could face the following error message: "Error SQL71562: Error validating element [dbo].[StoredProcedureNameExample]: Procedure: [dbo].[StoredProcedureNameExample] has an unresolved reference to object [DbNameExample].[SchemaNameExample].[TableNameExample]. External references are not supported when creating a package from this platform - (Microsoft.SqlServer.Dac) 

 

From the error message you can see you have a stored procedure [dbo].[StoredProcedureNameExample] that is referrencing a three part name object [DbNameExample].[SchemaNameExample].[TableNameExample]. It is not possible to export bacpac when object definitions contain external references, including references to themselves.

 

In this situation, you need to fix the issue and export again the database. Also, we would also recommend you not to export bacpac from an active database, it does not guarantee transactional consistency. You should set database to read-only mode or copy it to a new database and use this database as the source of export - See this URL for more reference Copy a database - Azure SQL Database | Microsoft Docs

 

Enjoy!

Posted at https://sl.advdat.com/3jL1qxPhttps://sl.advdat.com/3jL1qxP