日期:2014-05-18  浏览次数:20494 次

简单问题,求快速解决!
SQL code
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
 


1.执行b.userloginid+' '+tt.userloginid as SFA用户 字段合并后,如现如下情况:

km0009 100111
km0010 100122
km0001  
  100133
km0002  
  100144
  100155

结果:
km0009 100111
km0010 100122

1.字段合并后,只有两个字段都有数据的地方才会合并,其他的都是空,我想是数据类型的问题,但都是一个字段出来的数据.
请问高手怎么解决.  

2.还有就是我在这个视图的SELECT语句中使用函数的时候他提示没有列被找到,如:

SELECT stuff(DoradoReport.组织结构)

------解决方案--------------------
2.还有就是我在这个视图的SELECT语句中使用函数的时候他提示没有列被找到,如:
SELECT stuff(DoradoReport.组织结构)

前缀'DoradoReport' , 列名'组织结构'是否写正确了?