Advertisement
Guest User

Untitled

a guest
May 12th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DECLARE @Noeud int
  2. DECLARE @DateFinPeriode datetime
  3.  
  4. SET @DateFinPeriode = '23/02/2010 15:32'
  5.  
  6. select * from Agent ag WHERE ag.DateCreation < @DateFinPeriode AND (ag.DateInactif > @DateFinPeriode OR ag.DateInactif IS NULL)
  7.  
  8. SET @Noeud = 1
  9. WITH RechNoeud(PK_Noeud,FK_NoeudParent)
  10. AS (
  11.     SELECT n.PK_Noeud,n.FK_NoeudParent
  12.     FROM Noeud n
  13.     WHERE n.PK_Noeud = @Noeud
  14.     UNION ALL
  15.     SELECT n.PK_Noeud,n.FK_NoeudParent
  16.     FROM Noeud n
  17.     INNER JOIN RechNoeud r ON n.FK_NoeudParent = r.PK_Noeud
  18. )
  19. SELECT *
  20. FROM Agent ag
  21. INNER JOIN RechNoeud r ON (r.PK_Noeud = ag.FK_Noeud)
  22. WHERE ag.DateCreation < @DateFinPeriode AND (ag.DateInactif > @DateFinPeriode OR ag.DateInactif IS NULL)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement