Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.72 KB | None | 0 0
  1. USE iMartADW
  2. GO
  3.  
  4. DROP VIEW IF Exists extend.lkp_SchoolID
  5. GO
  6.  
  7. CREATE VIEW extend.lkp_SchoolID AS
  8. SELECT DISTINCT x.District_Id
  9.     , x.School_Id
  10.     , x.School_Unique_Id
  11. FROM dim_School_Current x
  12. GO
  13.  
  14.  
  15. DROP VIEW IF EXISTS extend.District_ID_Security
  16. GO
  17.  
  18. CREATE VIEW extend.District_ID_Security AS
  19. SELECT DISTINCT sc2.District_Id,
  20.     SUBSTRING(
  21.         (
  22.             SELECT sc1.school_unique_id + ',' AS [text()]
  23.             FROM extend.lkp_SchoolID sc1
  24.             WHERE sc1.District_ID = sc2.district_id
  25.             ORDER BY sc1.district_id, sc1.School_Id
  26.             FOR XML PATH ('')
  27.         ), 1, 1000) [School_Id_Security_All]
  28. FROM extend.lkp_SchoolID sc2
  29. GO
  30.  
  31.  
  32. Select * from extend.District_ID_Security
  33. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement