text: /* Station Doublon */
  select S.*
  		   from [NARC_eReleveData].dbo.TStations S 
  		   LEFT JOIN fieldActivity FA on FA.Name = S.FieldActivity_Name 
  		   JOIN StationType st ON  st.name = 'standard'
  		   LEFT JOIN Region R on r.Region = S.Region
  		   WHERe NOT EXISTS (select * from Station S2 where S2.LAT = S.LAT AND S2.LON = S.LON AND s2.LAT = S.LAT and S.[DATE] = S2.StationDate)
  		   AND (S.FieldActivity_ID != 27 or S.FieldActivity_ID IS NULL)
  		   AND EXISTS (SELECT * FROM [NARC_eReleveData].dbo.TStations S2 where S.TSta_PK_ID <> s2.TSta_PK_ID and isnull(S2.LAT,-1) =isnull(S.LAT,-1) and isnull(S2.LON,-1) =isnull(S.LON,-1) and S.[DATE] = S2.[DATE] AND S2.FieldActivity_ID != 27)
  		   ORDER BY S.LAT,S.LON,S.[Date]
  
  
  /* Station date vide */
  select S.*
  		   from [NARC_eReleveData].dbo.TStations S 
  		  WHERE S.DATE IS NULL
  
  
  SET IDENTITY_INSERT  [Station] ON
  
  	INSERT INTO [dbo].[Station]
             (
  		   ID
  		   ,[StationDate]
             ,[Name]
             ,[LAT]
             ,[LON]
             ,[ELE]
             ,[precision]
             ,[fieldActivityId]
             ,[creator]
             ,[creationDate]
             ,[FK_StationType]
             ,[FK_Region]
             ,[FK_MonitoredSite]
             ,[Place]
  		   ,Original_ID
  		   ,Comments
  		   )
  		   select DISTINCT S.TSta_PK_ID, isnull([DATE],creation_date)
  		   ,S.Name,S.LAT,S.LON,S.ELE,S.precision,FA.ID,S.creator,S.Creation_date,st.id,R.ID,MS.ID
  		   ,S.Place,'eReleve_'+CONVERT(VARCHAR,S.TSta_PK_ID),s.Comments
  		   from [NARC_eReleveData].dbo.TStations S 
  		   LEFT JOIN fieldActivity FA on FA.Name = S.FieldActivity_Name 
  		   JOIN StationType st ON  st.name = 'standard'
  		   LEFT JOIN Region R on r.Region = S.Region
  		   LEFT JOIN MonitoredSite MS ON MS.original_id = S.TSta_FK_TGeo_ID
  		   WHERe NOT EXISTS (select * from Station S2 where S2.LAT = S.LAT AND S2.LON = S.LON AND s2.LAT = S.LAT and S.[DATE] = S2.StationDate)
  		   AND (S.FieldActivity_ID != 27 or S.FieldActivity_ID IS NULL)
  		   AND NOT EXISTS (SELECT * FROM [NARC_eReleveData].dbo.TStations S2 where S.TSta_PK_ID <> s2.TSta_PK_ID and isnull(S2.LAT,-1) =isnull(S.LAT,-1) and isnull(S2.LON,-1) =isnull(S.LON,-1) and S.[DATE] = S2.[DATE] AND S2.FieldActivity_ID != 27)
  		   AND S.DATE IS NOT NULL
  	SET IDENTITY_INSERT  [Station] OFF	   
  
  ---------------------------------------DynProp Station Value -----------------------------------------------
  
  INSERT INTO StationDynPropValue (
  [StartDate]
        ,[ValueInt]
        ,[ValueString]
        ,[ValueDate]
        ,[ValueFloat]
        ,[FK_StationDynProp]
        ,[FK_Station]
  	)
  SELECT 
  ts.Date
  ,NULL
  ,CASE WHEN th.TTOP_Fullpath is nOT null THEn th.TTOP_Fullpath ELSE NULL END
  ,NULL
  ,NULL
  ,(SELECT ID From StationDynProp Where Name = 'Name_DistanceFromObs')
  ,s.ID
    FROM Station s 
    JOIN [NARC_eReleveData].[dbo].[TStations] ts 
  		on s.ID = ts.TSta_PK_ID
  LEFT JOIN THESAURUS.DBO.TTopic th on 
  	ttop_parentID = 1204084 and 204081+ts.Id_DistanceFromObs = ttop_PK_id
  where ts.Id_DistanceFromObs is not null 
  
  
  
  INSERT INTO StationDynPropValue (
  [StartDate]
        ,[ValueInt]
        ,[ValueString]
        ,[ValueDate]
        ,[ValueFloat]
        ,[FK_StationDynProp]
        ,[FK_Station]
  	)
  SELECT 
  Case WHEN ts.Date is null THen ts.creation_date ELSE ts.Date END
  ,ts.NbFieldWorker
  ,null
  ,NULL
  ,NULL
  ,(SELECT ID From StationDynProp Where Name = 'NbFieldWorker')
  ,s.ID
   FROM Station s 
   JOIN [NARC_eReleveData].[dbo].[TStations] ts 
  		on s.ID = ts.TSta_PK_ID
  where ts.NbFieldWorker is not null
  
  
  
  
  ---------------------------------------INSERT FieldWorker -----------------------------------------------
  
  INSERT INTO Station_FieldWorker (FK_Station,FK_FieldWorker)
  SELECT s2.ID,FieldWorker1
  FROM [NARC_eReleveData].dbo.TStations S 
  JOIN Station s2 ON S.TSta_PK_ID = s2.ID
  where s.FieldWorker1 is not null
  union all
  SELECT  s2.ID,FieldWorker2
  FROM [NARC_eReleveData].dbo.TStations S 
  JOIN Station s2 ON S.TSta_PK_ID = s2.ID
  where s.FieldWorker2 is not null
  union all
  SELECT  s2.ID,FieldWorker3
  FROM [NARC_eReleveData].dbo.TStations S 
  JOIN Station s2 ON S.TSta_PK_ID = s2.ID
  where s.FieldWorker3 is not null
  
  IF object_id('tempdb..#ProtToMigration') IS NOT NULL
  	DROP TABLE #ProtToMigration
  SELECT ProtocoleName into #ProtToMigration  from [MigrationConfigurationProtocoleList] L
  DECLARE @ProtocoleName VARCHAR(100)
  
  WHILE EXISTS (SELECT * FROM #ProtToMigration)
  BEGIN
  		
  		SELECT TOP 1 @ProtocoleName=ProtocoleName from #ProtToMigration
  	
  		exec pr_MigrationProtocole @ProtocoleName
  		DELETE FROM #ProtToMigration WHERE ProtocoleName=@ProtocoleName
  END
  
  