如何使用ssis composant将多行组合成具有不同列值的行

时间:2018-04-02 11:27:39

标签: sql sql-server ssis

我正在研究我的ETL,我必须在一行中将具有相同id的多行与不同列中的不同信息组合在一起。 在这里,它是我得到的和我想要使用ssis转换的一个例子。

Mat(PK)       Activity     EntryDate      Grade  
--------------------------------------------------
12             Null        01/01/2000      Null  
12             Dev          NULL          NULL   
12             NULL         NULL          Eng+8   

Mat(PK)       Activity     EntryDate      Grade  
---------------------------------------------------
12              Dev       01/01/2000      Eng+8  

我发出了一个sql请求,但是当我在OLE DB DESTINATION中添加此请求时,它返回该合成器不接受group by。 这是我的sql请求:

INSERT INTO [TestPFEDW].[dbo].[tsst]

SELECT DISTINCT
 [Matricule ]

,MAX([Prénom/Nom ])   AS [Nom_Complet]

  ,MAX([Consultant ?])AS [Consultant]
  ,MAX([Etat])          AS [Etat]
  ,MAX([Date Dém#])   AS [Date_Démmarage]
  ,MAX([Date Préavis])   AS [Date_Préavis]
  ,MAX([TN _Mission LD])   AS [TN _Mission LD]
  ,MAX([Manage])   AS [Manager]
  ,MAX([Observation])    AS [Observation]
  ,MAX([Entry Date]) AS [Date_Entrer]
  ,MAX([Date d'embauche])  AS [Date_Embauche]
  ,MAX([Ing/Tech])  AS [Ing/Tech]
  ,MAX([Expérience TOTALE as is_Rouge à corriger sur Sage]) AS [Expérience_Totale]
  ,MAX([Grade FI]) AS [Grade]
  ,MAX([Fonction_ATC])  AS [Fonction_ATC]
  ,MAX([Ancienneté Telnet_Au 1er Nov 2017]) AS [Ancienneté] 
  ,MAX([Spécialité])  AS [Spécialité]
  ,MAX([Natonalité])  AS [Natonalité]
  ,MAX([Date de sortie]) AS [Date_Sortie]
  ,MAX([Experience anterieur (mois)])AS [Experience_anterieur (mois)]
  ,MAX([Prestataire]) AS [Prestataire]
  ,MAX([Affiliation])  AS [Affiliation]
  ,MAX([Activité])  AS [Activité]

  FROM [TestPFEODS].[dbo].[Consultant]  AS A
  WHERE NOT EXISTS(SELECT * FROM [TestPFEDW].[dbo].[tsst] AS B WHERE B.[Matricule ] = A.[Matricule ]) and [Matricule ] like '%ATS%'  group by [Matricule ] 

1 个答案:

答案 0 :(得分:0)

您不能在OLDEDB目标中放置INSERT INTO语句。 在您的情况下,要么使用SQL任务,要么在DFT中添加OLEDB源和OLEDB目标。 在Source中添加您的select语句,并在Destination中选择您的表并相应地映射列