我们可以讨论如何使用 ssis 将以下查询结果加载到目标表中。我知道我们可以在 T-sql 中使用它,也可以作为 OLEDB 源查询。但仍然想知道如何实现它,只使用数据流组件
SELECT
CLIENTID = CAST(PER.CLIENTID AS INT)
,CASEID = CAST(CS.CASEID AS INT)
,CAST(RIGHT(ev.oid, 10) as int) AS EventID
,ev.ServiceSubtypeCode
,ev.ServiceSubtypeCode +' - '+ev.ServiceSubTypeDesc as ServiceSubTypeDesc
,WU.ProviderID as WorkunitProviderID
,WU.ProviderName as WorkUnitProviderName
,ev.eventstartdate as AssessmentStartDate
,CONVERT(CHAR(5),ASM.getstarttimestamp,8) as AssessmentStartTime
,ev.EVENTENDDATE as AssessmentEndDate
,ev.EVENTENDTIME as AssessmentEndTime
,CAST(asm.getAssmtTemplateName as nvarchar(200)) as AssessmentTypeDesc
,j.providerid
,j.ProviderName
,j.ProviderRole
,EV.ISCOMPLETED
, EV.ISFINALISED
,EV.ISREVOKED
, EV.REVOKEDDATE AS REVOKEDDATE
,ASM.OID AS ASSESSMENTID
FROM DBO.ASSESSMENT ASM
LEFT OUTER JOIN DBO.INDIVIDUALPERSON PER ON ASM.MYPERSON = PER.OID
LEFT OUTER JOIN DBO.[CASE] CS ON ASM.MYCASE = CS.OID
LEFT OUTER JOIN (
SELECT CAST(ST.CODE AS VARCHAR(8))AS SERVICETYPECODE
, CAST(ST.DESCRIPTION AS VARCHAR(100)) AS SERVICETYPEDESC
, CAST(SST.CODE AS VARCHAR(8)) AS SERVICESUBTYPECODE
, CAST(SST.DESCRIPTION AS VARCHAR(100)) AS SERVICESUBTYPEDESC
, DATEADD(DD,0, DATEDIFF(DD,0,EV.GETRPSSTARTTIMESTAMP)) AS EVENTSTARTDATE
, CONVERT(CHAR(5),EV.GETRPSSTARTTIMESTAMP,8) AS EVENTSTARTTIME
, DATEADD(DD,0, DATEDIFF(DD,0,EV.GETRPSENDTIMESTAMP)) AS EVENTENDDATE
, CONVERT(CHAR(5),EV.GETRPSENDTIMESTAMP,8) AS EVENTENDTIME
,CAST(VEN.DESCRIPTION AS VARCHAR(12)) AS EVENTVENUE
,EV.ISCOMPLETED
, EV.ISFINALISED
,EV.ISREVOKED
, DATEADD(DD,0, DATEDIFF(DD,0,EV.REVOKEDON)) AS REVOKEDDATE
, EV.OID
from Event ev
LEFT OUTER JOIN ServiceType AS st ON ev.myServiceType = st.oid
LEFT OUTER JOIN ServiceSubtype AS sst ON ev.myServiceSubtype = sst.oid
LEFT OUTER JOIN AllCodes AS ven ON ev.myEventVenueCode = ven.oid
)as EV
ON ASM.MYEVENT = EV.OID
LEFT OUTER JOIN (
select wu.oid
,CAST(wu.providerid AS VARCHAR(100)) AS providerid
,CAST(nm.getfullname AS VARCHAR(100)) AS ProviderName
,wu.contactname
,wu.activatedate as StartDate
,wu.deactivatedate as EndDate
,case when wu.deactivatedate is null then 1 else 0 end as IsActiveToday
from workunitprovider wu
LEFT OUTER JOIN dbo.allprovidernames nm ON wu.oid = nm.myprovider
where nm.myNameType in (02245.0000000252)
) as WU
ON ASM.MYWORKUNITPROVIDER = WU.OID
Left join (
select f.myEvent
,f.myProvider
,f.myproviderrolecode
,f.Max_ProvOid
,CAST(g.providerid AS VARCHAR(100)) AS providerid
,CAST( i.description AS VARCHAR(150)) AS ProviderRole
,cast (h.getFullName as nvarchar (150)) as ProviderName
from( select d.myEvent
,myProvider
,myproviderrolecode
,d.Max_ProvOid
from ( select A.myEvent, max(b.oid) as Max_ProvOid
from alleventitems a
left outer join ProviderEventItemRole as b on a.oid = b.myeventitem
group by A.myEvent
) as d
left join
( select A.myEvent,b.myProvider,b.myproviderrolecode,a.oid as a_oid,b.oid as b_oid
from alleventitems a
left outer join ProviderEventItemRole as b on a.oid = b.myeventitem
)as e on d.myevent = e.myevent and max_provOid = b_oid
) as f
left join dbo.allproviders as g on f.myProvider = g.oid
left join (
select *
from dbo.AllProviderNames
where mynametype ='02245.0000000252'
)as h on f.myprovider =h.myprovider
left join dbo.allcodes as i on f.myproviderrolecode = i.oid
)as j on ASM.myevent = j.myevent;