Sql Server 2019 Import Export Wizard Unable to cast object of type system.dbnull

Binway 716 Reputation points
2023-01-10T23:26:43.767+00:00

I am using the Sql Server 2019 Import export wizard to copy data from 16 tables in an Azure Sql Server Database to another Azure sql database in the same subscription, resource group etc. The wizard works fine for a table or two sometimes but when it fails or I select multiple tables I get this error:

- Setting Destination Connection (Error)
Messages
Error 0xc0047062: Destination - CapitalWork [97]: System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.Type'.
   at Microsoft.SqlServer.Dts.Pipeline.ADONETDestination.SetMetadataValsFromRow(DataRow currRow, String& name, Int32& codePage, Int32& length, Int32& precision, Int32& scale, DataType& dtsType)
   at Microsoft.SqlServer.Dts.Pipeline.ADONETDestination.SetExternalMetadataInfos(IDTSExternalMetadataColumnCollection100 iDTSExtCols, DataTable metadataTbl)
   at Microsoft.SqlServer.Dts.Pipeline.ADONETDestination.ReinitializeMetaData()
   at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostReinitializeMetaData(IDTSManagedComponentWrapper100 wrapper) (SQL Server Import and Export Wizard)
 
Unable to cast object of type 'System.DBNull' to type 'System.Type'. (Microsoft.SqlServer.DTSPipelineWrap)
 

The tables have a range of record counts from 1 million down to 1, the million record table works fine when activated by itself.

Thanks

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,491 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,664 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.