日期:2014-05-18 浏览次数:20494 次
ALTER VIEW [dbo].[V_Idata] AS
SELECT DoradoReport.组织结构,DoradoReport.中文姓+DoradoReport.中文名 as 员工姓名,DoradoReport.SAP工号 as 员工工号,SAP.SCALEID,PCB100BI,PCH100,PCR200,PCR100,
CTS.cts_ID as CTS用户,RMS_LOGONNAME as RMS用户,Domain_User.user_ad as 域用户,Domain_User2.userad2 as Internet用户,
Domain_User3.userad3 as VPN用户,b.userloginid+' '+tt.userloginid as SFA用户 ,notes.email as 邮箱用户
FROM DoradoReport LEFT outer join SAP ON DoradoReport.SAP工号=SAP.employee_ID
LEFT outer join notes ON DoradoReport.员工原工号=notes.PersonID or DoradoReport.SAP工号=notes.PersonID
LEFT outer join CTS ON DoradoReport.员工原工号=CTS.cts_ID OR DoradoReport.SAP工号=CTS.cts_ID
LEFT outer join RMS ON DoradoReport.员工原工号=RMS.RMS_ID OR DoradoReport.SAP工号=RMS.RMS_ID
LEFT outer join SFA ON DoradoReport.SAP工号=SFA.UserLoginID
left outer join
(select * from sfa
left outer join Domain_user on sfa.UserLoginID=Domain_user.user_ad and domain_user.user_kind='domain Users') tt on
DoradoReport.员工原工号=tt.user_id or DoradoReport.SAP工号=tt.user_id
/*LEFT outer join OA ON DoradoReport.SAP工号=OA.USERID OR DoradoReport.员工原工号=OA.USERID*/
LEFT outer join(
select [userloginid],username from sfa where ISNUMERIC([userloginid])=1
union all
select t2.user_id,t1.username from sfa t1 inner join domain_user t2 on t1.userloginid=t2.user_ad
where ISNUMERIC(t1.[userloginid])=0 and t2.user_kind='DOMAIN_USER'
)b on DoradoReport.SAP工号=b.[userloginid]
LEFT outer join(select * from Domain_User where User_kind='Domain Users') Domain_User ON DoradoReport.员工原工号=Domain_User.user_id or DoradoReport.SAP工号=Domain_User.user_id
LEFT outer join(select user_ad as userad2,user_kind,user_username,user_id from Domain_User where User_kind='Internet Users') Domain_User2 ON DoradoReport.员工原工号=Domain_User2.user_id or DoradoReport.SAP工号=Domain_User2.user_id
LEFT outer join(select user_ad as userad3,user_kind,user_username,user_id from Domain_User where User_kind='VPN Users' or User_kind='VPN Users2') Domain_User3 ON DoradoReport.员工原工号=Domain_User3.user_id or DoradoReport.SAP工号=Domain_User3.user_id