From 5cb9c25d68bd7499fd6a7be0c35553485d10c51e Mon Sep 17 00:00:00 2001 From: "m.semalaiappan" Date: Thu, 7 Nov 2024 10:13:37 -0600 Subject: [PATCH] CREATE OR ALTER VIEW Added for Auth View --- ...490-RemoveClusteredIndexesFromAuthView.sql | 26 +++------------- ...490-RemoveClusteredIndexesFromAuthView.sql | 31 +++---------------- 2 files changed, 10 insertions(+), 47 deletions(-) diff --git a/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Structure/Ods/1490-RemoveClusteredIndexesFromAuthView.sql b/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Structure/Ods/1490-RemoveClusteredIndexesFromAuthView.sql index 1a0058e650..f8627aae76 100644 --- a/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Structure/Ods/1490-RemoveClusteredIndexesFromAuthView.sql +++ b/Application/EdFi.Ods.Standard/Standard/4.0.0/Artifacts/MsSql/Structure/Ods/1490-RemoveClusteredIndexesFromAuthView.sql @@ -10,11 +10,7 @@ IF EXISTS (SELECT 1 DROP INDEX UX_EducationOrganizationIdToStudentUSI ON auth.EducationOrganizationIdToStudentUSI; GO -IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStudentUSI')) - DROP VIEW auth.EducationOrganizationIdToStudentUSI; -GO - -CREATE VIEW auth.EducationOrganizationIdToStudentUSI AS +CREATE OR ALTER VIEW auth.EducationOrganizationIdToStudentUSI AS SELECT edOrgs.SourceEducationOrganizationId, ssa.StudentUSI, COUNT_BIG(*) AS Ignored FROM auth.EducationOrganizationIdToEducationOrganizationId edOrgs INNER JOIN edfi.StudentSchoolAssociation ssa @@ -29,12 +25,8 @@ IF EXISTS (SELECT 1 DROP INDEX UX_EducationOrganizationIdToParentUSI ON auth.EducationOrganizationIdToParentUSI; GO -IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToParentUSI')) - DROP VIEW auth.EducationOrganizationIdToParentUSI; -GO - CREATE OR ALTER VIEW auth.EducationOrganizationIdToParentUSI AS - SELECT edOrgs.SourceEducationOrganizationId, spa.ParentUSI + SELECT edOrgs.SourceEducationOrganizationId, spa.ParentUSI, COUNT_BIG(*) AS Ignored FROM auth.EducationOrganizationIdToEducationOrganizationId edOrgs INNER JOIN edfi.StudentSchoolAssociation ssa ON edOrgs.TargetEducationOrganizationId = ssa.SchoolId @@ -43,11 +35,7 @@ CREATE OR ALTER VIEW auth.EducationOrganizationIdToParentUSI AS GROUP BY edOrgs.SourceEducationOrganizationId, spa.ParentUSI GO -IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStaffUSI')) - DROP VIEW auth.EducationOrganizationIdToStaffUSI; -GO - -CREATE VIEW auth.EducationOrganizationIdToStaffUSI AS +CREATE OR ALTER VIEW auth.EducationOrganizationIdToStaffUSI AS -- EdOrg Assignments SELECT edOrgs.SourceEducationOrganizationId, seo_assign.StaffUSI @@ -64,14 +52,10 @@ CREATE VIEW auth.EducationOrganizationIdToStaffUSI AS ON edOrgs.TargetEducationOrganizationId = seo_empl.EducationOrganizationId GO -IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStudentUSIThroughResponsibility')) - DROP VIEW auth.EducationOrganizationIdToStudentUSIThroughResponsibility; -GO - -CREATE VIEW auth.EducationOrganizationIdToStudentUSIThroughResponsibility AS +CREATE OR ALTER VIEW auth.EducationOrganizationIdToStudentUSIThroughResponsibility AS SELECT edOrgs.SourceEducationOrganizationId, seora.StudentUSI FROM auth.EducationOrganizationIdToEducationOrganizationId edOrgs INNER JOIN edfi.StudentEducationOrganizationResponsibilityAssociation seora ON edOrgs.TargetEducationOrganizationId = seora.EducationOrganizationId GROUP BY edOrgs.SourceEducationOrganizationId, seora.StudentUSI -GO \ No newline at end of file +GO diff --git a/Application/EdFi.Ods.Standard/Standard/5.2.0/Artifacts/MsSql/Structure/Ods/1490-RemoveClusteredIndexesFromAuthView.sql b/Application/EdFi.Ods.Standard/Standard/5.2.0/Artifacts/MsSql/Structure/Ods/1490-RemoveClusteredIndexesFromAuthView.sql index 875ee1f17f..fda770cb89 100644 --- a/Application/EdFi.Ods.Standard/Standard/5.2.0/Artifacts/MsSql/Structure/Ods/1490-RemoveClusteredIndexesFromAuthView.sql +++ b/Application/EdFi.Ods.Standard/Standard/5.2.0/Artifacts/MsSql/Structure/Ods/1490-RemoveClusteredIndexesFromAuthView.sql @@ -10,13 +10,7 @@ IF EXISTS (SELECT 1 DROP INDEX UX_EducationOrganizationIdToStudentUSI ON auth.EducationOrganizationIdToStudentUSI; GO - -IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStudentUSI')) - DROP VIEW auth.EducationOrganizationIdToStudentUSI; -GO - - -CREATE VIEW auth.EducationOrganizationIdToStudentUSI AS +CREATE OR ALTER VIEW auth.EducationOrganizationIdToStudentUSI AS SELECT edOrgs.SourceEducationOrganizationId, ssa.StudentUSI, COUNT_BIG(*) AS Ignored FROM auth.EducationOrganizationIdToEducationOrganizationId edOrgs INNER JOIN edfi.StudentSchoolAssociation ssa @@ -24,7 +18,6 @@ CREATE VIEW auth.EducationOrganizationIdToStudentUSI AS GROUP BY edOrgs.SourceEducationOrganizationId, ssa.StudentUSI GO - IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = 'UX_EducationOrganizationIdToContactUSI' @@ -32,12 +25,7 @@ IF EXISTS (SELECT 1 DROP INDEX UX_EducationOrganizationIdToContactUSI ON auth.EducationOrganizationIdToContactUSI; GO - -IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToContactUSI')) - DROP VIEW auth.EducationOrganizationIdToContactUSI; -GO - -CREATE VIEW auth.EducationOrganizationIdToContactUSI AS +CREATE OR ALTER VIEW auth.EducationOrganizationIdToContactUSI AS SELECT edOrgs.SourceEducationOrganizationId, spa.ContactUSI, COUNT_BIG(*) AS Ignored FROM auth.EducationOrganizationIdToEducationOrganizationId edOrgs INNER JOIN edfi.StudentSchoolAssociation ssa @@ -47,12 +35,7 @@ CREATE VIEW auth.EducationOrganizationIdToContactUSI AS GROUP BY edOrgs.SourceEducationOrganizationId, spa.ContactUSI GO -IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStaffUSI')) - DROP VIEW auth.EducationOrganizationIdToStaffUSI; -GO - - -CREATE VIEW auth.EducationOrganizationIdToStaffUSI AS +CREATE OR ALTER VIEW auth.EducationOrganizationIdToStaffUSI AS -- EdOrg Assignments SELECT edOrgs.SourceEducationOrganizationId, seo_assign.StaffUSI @@ -69,14 +52,10 @@ CREATE VIEW auth.EducationOrganizationIdToStaffUSI AS ON edOrgs.TargetEducationOrganizationId = seo_empl.EducationOrganizationId GO -IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStudentUSIThroughResponsibility')) - DROP VIEW auth.EducationOrganizationIdToStudentUSIThroughResponsibility; -GO - -CREATE VIEW auth.EducationOrganizationIdToStudentUSIThroughResponsibility AS +CREATE OR ALTER VIEW auth.EducationOrganizationIdToStudentUSIThroughResponsibility AS SELECT edOrgs.SourceEducationOrganizationId, seora.StudentUSI FROM auth.EducationOrganizationIdToEducationOrganizationId edOrgs INNER JOIN edfi.StudentEducationOrganizationResponsibilityAssociation seora ON edOrgs.TargetEducationOrganizationId = seora.EducationOrganizationId GROUP BY edOrgs.SourceEducationOrganizationId, seora.StudentUSI -GO \ No newline at end of file +GO