SSIS package 排序不成功

0
SSIS package coding如下:
SELECT
      YEAR(AL1.GMTCreatedDateTime) as Open_Year,
      Month(AL1.GMTCreatedDateTime) as Open_Month,
      CONVERT(varchar(100),dateadd(dd,-datepart(weekday,AL1.GMTCreatedDateTime)+8,AL1.GMTCreatedDateTime), 101) as Week_Number,
      AL1.ServiceRequestId,
      AL1.GMTCreatedDateTime,
      AL1.GMTFirstAgentMsgDateTime,
      AL1.GMTFirstAssignedDateTime,
      AL1.GMTClosedDateTime,
      AL1.ResolutionCode,
      datepart(HOUR,AL1.GMTCreatedDateTime) as Hour_Created,
      AL1.SecondsUntilFirstAgentMsg,
      CONVERT(varchar(100),AL1.GMTCreatedDateTime, 101) as Create_DAY,
      cast(round(AL1.SecondsUntilFirstAgentMsg*1.0/60,2) as numeric(9,2)) as Reply_Times_Final,
      case when AL1.SecondsUntilFirstAgentMsg>120 then '0'
      else '1' end as SL_met_miss,
      AL2.QueueName as CurrentQueueName,
      AL3.QueueName as InitialQueueName,
      case when AL2.QueueName=AL3.QueueName then '0'
      else '1' end as Misroute,
      AL1.WorkTimeSeconds,
      case when AL1.GMTFirstAgentMsgDateTime IS null then '1'
      else '0' end as Abandoned,
      AL6.Countryname,
      AL1.IsUnderWarranty,
      AL1.ExternalRefKey,
      AL1.RemoteControlUsedCount,
      AL1.RemoteControlTimeInSeconds,
      AL1.SRCreateMethod,
      AL1.ProductNo,
      upper(AL1.SerialNo) as SerialNumber,
      AL1.EntitlementStatus,
      1 as Event_Count,
      ROW_NUMBER() over(partition by AL1.ExternalRefKey order by AL1.ExternalRefKey) as Case_Event_Count,
      AL4.Gmtcurrenteventdate,
      AL4.Gmtnexteventdate,
      DATEDIFF(s,AL4.Gmtcurrenteventdate,AL4.Gmtnexteventdate) as Event_Time_Sec,
      AL5.[FirstName]+'_'+AL5.[LastName] as Event_Agent
      
  FROM 
  [dbo].[SRFact] AL1 left join [dbo].[Countrydim] AL6 on AL1.Countrydimid=AL6.Countrydimid
  left join [dbo].[QueueDim] AL3 on AL1.InitialQueueDimId=AL3.QueueDimId
  left join [dbo].[QueueDim] AL2 on AL1.CurrentQueueDimId=AL2.QueueDimId
  full join [dbo].[Srassignmenthistory] AL4 on AL1.ServiceRequestId=AL4.ServiceRequestId
  join [dbo].[AgentDim] AL5 on AL4.AgentDimId=AL5.AgentDimID
  
  where (AL1.GMTCreatedDateTime>=DATEADD(d,-60,getdate()))
  and (AL3.QueueName in (
**数百条queue list**
  ))
  order by AL1.ServiceRequestId, AL4.Gmtcurrenteventdate
 
需要达到的目的是数据以ServiceRequestId,Gmtcurrenteventdate的优先次序排序,但目的没有达到。在写入表中的4万多条数据好像分成很多段,每段内的数据是按照要求排序的,但段与段之间没有。
 
后来希望通过 sort 功能排序,但也没有成功。
 
附上截图,

1.JPG


2.JPG


4.JPG

显示数据未正确排序。
 

5.JPG


6.JPG

显示 sort功能的设置。

请教各位如何解决?多谢!
已邀请:
0

BIWORK - 热衷于微软BI技术,技术架构和解决方案! 2015-10-22 回答

我的理解:数据流到 OLE DB Destination 也只是一批一批提交数据的,将整个数据流分段比如1000行,或者10000行提交到目标表中,这个是非常正常的。Sort 控件的作用只是对源排序,比如在用到 Merge 等控件的时候,对目标不起作用。

目标表的数据顺序无所谓,下次查询使用的时候排序一下就可以了,完全不用考虑这些顺序的问题。 因为在 SSIS 里面不像事务处理系统的数据是一条一条处理,一定是和操作时间顺序一致,SSIS 中这几个控件不是这样的。

你可以试着把 OLE DB Destination 中的 Bulk Insert 改成普通的 Insert 看看有没有区别。

其实输出结果在目标表里排序不排序我看来没有什么区别,不用考虑这个问题了。
0

天桥下的郑成功 - Hadoop大数据开发工程师、数仓架构师、熟悉数据仓库设计、Hadoop、Spark、HBase、Hive、SSIS等开发 2015-10-22 回答

上面那个查询是在 OLEDBSource里写的吗? 那么你的数据已经是经过排序的
在Lookup后, 为何还要再次排序

要回复问题请先登录注册