Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. SELECT
  2. RT.Id, RT.manager_id, RT.worksite_id, RT.hire_reason_id, RT.ref, RT.notes, RT.can_claim_expenses, RT.[State]
  3. ,JA.org_unit_id, JA.job_position_id
  4. -- ,RA.credential_type_id, RA.[rank], RA.essential
  5. -- ,OA.OA_id, OA.contract_type, OA.n_vacancies
  6.  
  7. FROM OPENJSON(@JSON)
  8. WITH
  9. (
  10. id INT
  11. ,manager_id INT
  12. ,worksite_id INT
  13. ,hire_reason_id INT
  14. ,ref NVARCHAR(500)
  15. ,notes NVARCHAR(500)
  16. ,can_claim_expenses NVARCHAR(50)
  17. ,[state] NVARCHAR(50)
  18. ,identifiers NVARCHAR(50)
  19. ,job_attributes NVARCHAR(MAX) AS JSON
  20. ) RT
  21. CROSS APPLY OPENJSON (RT.job_attributes)
  22. WITH
  23. (
  24. org_unit_id INT
  25. ,job_position_id INT
  26. ,requirements_attributes NVARCHAR(MAX) AS JSON
  27. ) JA
  28. CROSS APPLY OPENJSON (JA.requirements_attributes)
  29. WITH
  30. (
  31. credential_type_id INT
  32. ,[rank] INT
  33. ,essential BIT
  34. ,openings_attributes NVARCHAR(MAX) AS JSON
  35. ) RA
  36. /* --Uncomment #1
  37. CROSS APPLY OPENJSON (RA.openings_attributes)
  38. WITH
  39. (
  40. OA_id INT '$.id'
  41. ,contract_type NVARCHAR(50)
  42. ,n_vacancies INT
  43. ,rostered_shifts_attributes NVARCHAR(MAX) AS JSON
  44. ) OA
  45. */
  46. /* --Uncomment #2
  47. CROSS APPLY OPENJSON (OA.rostered_shifts_attributes)
  48. WITH
  49. (
  50. id INT
  51. ,starts_at datetime
  52. ,ends_at datetime
  53. ,notes NVARCHAR(500)
  54. ,on_call BIT
  55. )
  56. RSA
  57. */
  58. `
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement