Advertisement
yuvarajupadhyaya

View Learn

Jul 18th, 2022
4,365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.16 KB | None | 0 0
  1. USE [MeshedEducationV2]
  2. GO
  3.  
  4. /****** Object:  View [Common].[LookupDetailView]    Script Date: 18/07/2022 7:10:37 PM ******/
  5. SET ANSI_NULLS ON
  6. GO
  7.  
  8. SET QUOTED_IDENTIFIER ON
  9. GO
  10.  
  11. CREATE VIEW [Common].[LookupDetailView]
  12.     AS
  13.  
  14.     SELECT lud.Id AS ParentId,lud.LookUpName AS ParentName,lud.LookUpValue AS ParentValue, lud.LookupDescription AS ParentDescription
  15. ,lud.IsActive AS IsParentActive, lud.DisplaySequence AS ParentDisplaySequence,
  16.  
  17. lud3.Id AS ReferenceParentId  ,lud3.LookUpName AS ReferenceParentName,lud3.LookUpValue AS ReferenceParentValue, lud3.LookupDescription AS ReferenceParentDescription
  18. ,lud3.IsActive AS IsReferenceParentActive, lud3.DisplaySequence AS ReferenceParentDisplaySequence,
  19.  
  20. lud2.Id AS ChildId,lud2.LookUpName AS ChildName,lud2.LookUpValue AS ChildValue, lud2.LookupDescription AS ChildDescription
  21. ,lud2.ParentLookUpId
  22. ,lud2.IsActive AS IsChildActive,lud2.DisplaySequence AS ChildDisplaySequence, lud2.VetCode AS ChildVetCode
  23. FROM Common.LookUpDetail lud LEFT JOIN Common.LookUpDetail lud2
  24. ON lud.Id = lud2.ParentLookUpId
  25. LEFT JOIN Common.LookUpDetail lud3
  26. ON lud3.Id = lud2.referencelookupid
  27. WHERE lud.ParentLookUpId IS NULL
  28. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement