Cast following INT variables to varchar.
@TempBatchNumber
@SourceSystemID
@EDWSourceSystemID
Set @DeltaSizeSQL =
'Select SUM(A.DeltaCount * B.AvgRecordSize) from '+'.'+@Databasename+'.dbo.parameterhistory A
Join Operations..DatasetTables B (Nolock) ON A.ReferenceObjectName =...