I included the sql statement from the stored procedure below. When I execute this statement it fails. It seems to be a data issue but I can't find anything in the data that looks unusual like a character in an integer defined field. Its been running for months without an issue. I was hoping I could somehow see the field or row that it fails on. Is there a method to display the field or row in error?
insert into [CRM].[FactEvents]
select
a.EventID
,a.CampaignID
,case when a.AccountID is NULL
then 0
else a.OpportunityID
end as OpportunityID
,a.AccountID
,a.ContactID
,a.ContactEventID
,row_number() over (partition by a.ContactEventID order by a.ContactEventID) as UniqueID
,a.DateID
,a.EventTypeID
,a.AttendedID
,case when a.MarketSegmentID is NULL
then 0
else a.MarketSegmentID
end as MarketSegmentID
,a.AttendeeCategoryID
,a.ExperienceTypeID
,a.CampaignStatusID
,a.Exhibitor
,a.Staff
,a.Guest
,a.Speaker
,a.Sponsor
,a.Press
,a.CPECredit
,a.Location
,min(b.ZipCode) as PostalCode
,a.UtilizationType
,a.EventName
,a.AdmissionItem
,a.StartDate
,a.EndDate
,case when a.RegistrationDate > a.EndDate
then a.StartDate
else a.RegistrationDate
end as RegistrationDate
,AmountDue
,AmountPaid
,cast(EventTypeID as varchar) + '-' + cast(case when RegistrationDate > EndDate then StartDate else RegistrationDate end as varchar) as EventRegistrationID
,a.Cancelled
,rtrim(replace(
case when a.Exhibitor + a.Staff + a.Guest + a.Speaker + a.Sponsor + a.Press = 0
then 'Attendee/'
when a.Exhibitor + a.Staff + a.Guest + a.Speaker + a.Sponsor + a.Press > 0
then case when a.Exhibitor = 1
then 'Exhibitor/'
else ''
end
- case when a.Staff = 1
then 'Staff/'
else ''
end - case when a.Guest = 1
then 'Guest/'
else ''
end - case when a.Speaker = 1
then 'Speaker/'
else ''
end - case when a.Sponsor = 1
then 'Sponsor/'
else ''
end - case when a.Press = 1
then 'Press/'
else ''
end
else 'Other/'
end
,'/',' ')) as AttendeeCategories
,a.MemberProductTypeID
,NewReturningGuestID = 0
from #FactEventStaging a
left outer join [Shared].[DimUSZipCodes] b
on a.Location = b.City
and b.ZipCodeType = 'Standard'
and b.Decommissioned = 0
and b.CityRank is not NULL
left outer join [Staging].[DimAccount] c
on a.AccountID = c.AccountID
left outer join [CRM].[DimMarketSegment] d
on c.MarketSegmentCode = d.CRMValue
group by a.EventID
,a.CampaignID
,a.OpportunityID
,a.AccountID
,a.ContactID
,a.ContactEventID
,a.DateID
,a.EventTypeID
,a.AttendedID
,a.MarketSegmentID
,a.AttendeeCategoryID
,a.ExperienceTypeID
,a.CampaignStatusID
,a.Exhibitor
,a.Staff
,a.Guest
,a.Speaker
,a.Sponsor
,a.Press
,a.CPECredit
,a.Location
,a.UtilizationType
,a.EventName
,a.AdmissionItem
,a.StartDate
,a.EndDate
,a.RegistrationDate
,a.AmountDue
,a.AmountPaid
,a.Cancelled
,a.MemberProductTypeID