Hello Folks i'm trying to union all two select stmts in which Closeddate and reopeneddates are varchar in one Table and date time in other Table. How to convert the field to be compatible with the other stmt without having Errors.
here is the sqlstmt
select * into ##Temp9
from
(select [Month],
[Year],
[claimnumber],
[ClaimantSequence],
[Claimid1],
[AgeofClaim],
[SetupDate],
[ClosedDate],
[ReopenedDate],
[ReopenedDaysOpen],
[LossStatusId],
[ReceivedDate],
[TotalLossPaid_ITD],
[TotalExppaid_ITD],
[totalpaid_ITD],
[totallossres_itd],
[totalexpenseres_itd],
[totalRes_ITD],
[totalIncrd_ITD],
[featurestatus],
[lossst],
[lobtype],
[AM_incl_excl_flag],
[agtgrp],
[handlingOfc],
[lossdate],
[lossYear],
[examiner],
[Count],
NULL as [Reopened],
[Tippett],
[Supervisor],
NULL as [Office],
[Region],
[ClaimType],
[Status],
[companyname],
[policy],
[policysourceid],
[dateeffective],
NULL as [Lasttransactiondate],
NULL as [ASL],
NULL as[Source],
NULL as[Group],
NULL as[ExpIncurred],
NULL as[ExpIncurredRatio],
NULL as[Range],
'New' as Flag,'Pending' as Flag
from [dbo].[ProductionPending2019]
UNION ALL
select [Month],
[Year],
[claimnumber],
[ClaimantSequence],
[Claimid1],
[AgeofClaim],
[SetupDate],
CONVERT(datetime,[ClosedDate]),
CONVERT(datetime,[ReopenedDate]),
[ReopenedDaysOpen],
[LossStatusId],
[ReceivedDate],
[TotalLossPaid_ITD],
[TotalExppaid_ITD],
[totalpaid_ITD],
[totallossres_itd],
[totalexpenseres_itd],
[totalRes_ITD],
[totalIncrd_ITD],
[featurestatus],
[lossst],
[lobtype],
[AM_incl_excl_flag],
[agtgrp],
[handlingOfc],
[lossdate],
[lossYear],
[examiner],
[Count],
NULL as [Reopened],
[Tippett],
[Supervisor],
NULL as [Office],
[Region],
[ClaimType],
[Status],
[companyname],
[policy],
[policysourceid],
[dateeffective],
NULL as [Lasttransactiondate],
NULL as [ASL],
NULL as[Source],
NULL as[Group],
NULL as[ExpIncurred],
NULL as[ExpIncurredRatio],
NULL as[Range],
'New' as Flag
from [dbo].[ProductionNew2019])
a