syncro
This commit is contained in:
@@ -4,144 +4,298 @@ BEGIN TRANSACTION;
|
||||
SET XACT_ABORT ON;
|
||||
|
||||
|
||||
INSERT INTO upd.IA_IndexesAlignementActions
|
||||
(
|
||||
IA_executionDate,
|
||||
IA_schema_name,
|
||||
IA_table_name,
|
||||
IA_columns_name,
|
||||
IA_is_clustered,
|
||||
IA_is_unique,
|
||||
IA_included_columns,
|
||||
IA_is_to_be_deleted,
|
||||
IA_is_to_be_recreated,
|
||||
IA_expected_index_name,
|
||||
IA_foundIndexName,
|
||||
IA_wasIndexFound,
|
||||
IA_wasCreated,
|
||||
IA_wasRenamed,
|
||||
IA_wasDeleted,
|
||||
IA_wasRecreated,
|
||||
IA_includedColumnsMatch,
|
||||
IA_actualColumns,
|
||||
IA_actualIncludedColumns,
|
||||
IA_statusMsg,
|
||||
IA_index_options
|
||||
)
|
||||
SELECT
|
||||
NULL AS IA_executionDate,
|
||||
'dbo' AS IA_schema_name,
|
||||
'Criteria' AS IA_table_name,
|
||||
'CR_code, CR_criteria_type' AS IA_columns_name,
|
||||
0 AS IA_is_clustered,
|
||||
1 AS IA_is_unique,
|
||||
NULL AS IA_included_columns,
|
||||
0 AS IA_is_to_be_deleted,
|
||||
0 AS IA_is_to_be_recreated,
|
||||
'NCIX_Criteria_COL_CR_code' AS IA_expected_index_name,
|
||||
NULL AS IA_foundIndexName,
|
||||
0 AS IA_wasIndexFound,
|
||||
0 AS IA_wasCreated,
|
||||
0 AS IA_wasRenamed,
|
||||
0 AS IA_wasDeleted,
|
||||
0 AS IA_wasRecreated,
|
||||
NULL AS IA_includedColumnsMatch,
|
||||
NULL AS IA_actualColumns,
|
||||
NULL AS IA_actualIncludedColumns,
|
||||
NULL AS IA_statusMsg ,
|
||||
NULL AS IA_index_options
|
||||
UNION
|
||||
SELECT
|
||||
NULL AS IA_executionDate,
|
||||
'dbo' AS IA_schema_name,
|
||||
'Criteria' AS IA_table_name,
|
||||
'CR_criteria_type' AS IA_columns_name,
|
||||
0 AS IA_is_clustered,
|
||||
0 AS IA_is_unique,
|
||||
NULL AS IA_included_columns,
|
||||
0 AS IA_is_to_be_deleted,
|
||||
0 AS IA_is_to_be_recreated,
|
||||
'NCIX_Criteria_COL_CR_criteria_type' AS IA_expected_index_name,
|
||||
NULL AS IA_foundIndexName,
|
||||
0 AS IA_wasIndexFound,
|
||||
0 AS IA_wasCreated,
|
||||
0 AS IA_wasRenamed,
|
||||
0 AS IA_wasDeleted,
|
||||
0 AS IA_wasRecreated,
|
||||
NULL AS IA_includedColumnsMatch,
|
||||
NULL AS IA_actualColumns,
|
||||
NULL AS IA_actualIncludedColumns,
|
||||
NULL AS IA_statusMsg ,
|
||||
NULL AS IA_index_options
|
||||
UNION
|
||||
SELECT
|
||||
NULL AS IA_executionDate,
|
||||
'dbo' AS IA_schema_name,
|
||||
'Criteria' AS IA_table_name,
|
||||
'CR_master_ID' AS IA_columns_name,
|
||||
0 AS IA_is_clustered,
|
||||
0 AS IA_is_unique,
|
||||
NULL AS IA_included_columns,
|
||||
0 AS IA_is_to_be_deleted,
|
||||
01 AS IA_is_to_be_recreated,
|
||||
'NCIX_Criteria_COL_CR_master_ID' AS IA_expected_index_name,
|
||||
NULL AS IA_foundIndexName,
|
||||
0 AS IA_wasIndexFound,
|
||||
0 AS IA_wasCreated,
|
||||
0 AS IA_wasRenamed,
|
||||
0 AS IA_wasDeleted,
|
||||
0 AS IA_wasRecreated,
|
||||
NULL AS IA_includedColumnsMatch,
|
||||
NULL AS IA_actualColumns,
|
||||
NULL AS IA_actualIncludedColumns,
|
||||
NULL AS IA_statusMsg,
|
||||
NULL AS IA_index_options
|
||||
UNION
|
||||
SELECT
|
||||
NULL AS IA_executionDate,
|
||||
'dbo' AS IA_schema_name,
|
||||
'Criteria' AS IA_table_name,
|
||||
'CR_VGUID' AS IA_columns_name,
|
||||
0 AS IA_is_clustered,
|
||||
0 AS IA_is_unique,
|
||||
NULL AS IA_included_columns,
|
||||
0 AS IA_is_to_be_deleted,
|
||||
0 AS IA_is_to_be_recreated,
|
||||
'NCIX_Criteria_COL_CR_VGUID' AS IA_expected_index_name,
|
||||
NULL AS IA_foundIndexName,
|
||||
0 AS IA_wasIndexFound,
|
||||
0 AS IA_wasCreated,
|
||||
0 AS IA_wasRenamed,
|
||||
0 AS IA_wasDeleted,
|
||||
0 AS IA_wasRecreated,
|
||||
NULL AS IA_includedColumnsMatch,
|
||||
NULL AS IA_actualColumns,
|
||||
NULL AS IA_actualIncludedColumns,
|
||||
NULL AS IA_statusMsg ,
|
||||
NULL AS IA_index_options
|
||||
UNION
|
||||
SELECT
|
||||
NULL AS IA_executionDate,
|
||||
'dbo' AS IA_schema_name,
|
||||
'Criteria' AS IA_table_name,
|
||||
'Criteria_ID' AS IA_columns_name,
|
||||
1 AS IA_is_clustered,
|
||||
1 AS IA_is_unique,
|
||||
NULL AS IA_included_columns,
|
||||
0 AS IA_is_to_be_deleted,
|
||||
0 AS IA_is_to_be_recreated,
|
||||
'PK_Criteria_ID' AS IA_expected_index_name,
|
||||
NULL AS IA_foundIndexName,
|
||||
0 AS IA_wasIndexFound,
|
||||
0 AS IA_wasCreated,
|
||||
0 AS IA_wasRenamed,
|
||||
0 AS IA_wasDeleted,
|
||||
0 AS IA_wasRecreated,
|
||||
NULL AS IA_includedColumnsMatch,
|
||||
NULL AS IA_actualColumns,
|
||||
NULL AS IA_actualIncludedColumns,
|
||||
NULL AS IA_statusMsg ,
|
||||
NULL AS IA_index_options
|
||||
|
||||
/* OCTPDBA-414: table dbo.criteria, pharmacy only*/
|
||||
|
||||
/* CR_code, CR_criteria_type */
|
||||
INSERT INTO [Arizona].[upd].[IA_IndexAlignementActions]
|
||||
(
|
||||
[IA_executionDate],
|
||||
[IA_schemaName],
|
||||
[IA_tableName],
|
||||
[IA_columnsName],
|
||||
[IA_isClustered],
|
||||
[IA_isUnique],
|
||||
[IA_includedColumns],
|
||||
[IA_isToBeDeleted],
|
||||
[IA_isToBeRecreated],
|
||||
[IA_expectedIndexName],
|
||||
[IA_foundIndexName],
|
||||
[IA_wasIndexFound],
|
||||
[IA_wasCreated],
|
||||
[IA_wasRenamed],
|
||||
[IA_wasDeleted],
|
||||
[IA_wasRecreated],
|
||||
[IA_includedColumnsMatch],
|
||||
[IA_actualColumns],
|
||||
[IA_actualIncludedColumns],
|
||||
[IA_statusMsg],
|
||||
[IA_indexOptions],
|
||||
[IA_reference]
|
||||
)
|
||||
SELECT
|
||||
NULL as [IA_executionDate],
|
||||
'dbo' as [IA_schemaName],
|
||||
'Criteria' as [IA_tableName],
|
||||
'CR_code, CR_criteria_type' as [IA_columnsName],
|
||||
0 as [IA_isClustered],
|
||||
1 as [IA_isUnique],
|
||||
NULL as [IA_includedColumns],
|
||||
0 as [IA_isToBeRecreated],
|
||||
0 as [IA_isToBeRecreated],
|
||||
'NCIX_Criteria_COL_CR_code' as [IA_expectedIndexName],
|
||||
NULL as [IA_foundIndexName],
|
||||
0 as [IA_wasIndexFound],
|
||||
0 as [IA_wasCreated],
|
||||
0 as [IA_wasRenamed],
|
||||
0 as [IA_wasDeleted],
|
||||
0 as [IA_wasRecreated],
|
||||
NULL as [IA_includedColumnsMatch],
|
||||
NULL as [IA_actualColumns],
|
||||
NULL as [IA_actualIncludedColumns],
|
||||
NULL as [IA_statusMsg],
|
||||
'STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, SORT_IN_TEMPDB = OFF, FILLFACTOR =90' as IA_index_options,
|
||||
'OCTPDBA-414' AS [IA_reference]
|
||||
WHERE NOT EXISTS(
|
||||
SELECT 1
|
||||
FROM [Arizona].[upd].[IA_IndexAlignementActions] s
|
||||
WHERE [s].[IA_schemaName] = 'dbo'
|
||||
AND [s].[IA_tableName] = 'Criteria'
|
||||
AND [s].[IA_columnsName] = 'CR_code, CR_criteria_type'
|
||||
AND [s].[IA_reference] = 'OCTPDBA-414'
|
||||
)
|
||||
|
||||
/* CR_criteria_type */
|
||||
INSERT INTO [Arizona].[upd].[IA_IndexAlignementActions]
|
||||
(
|
||||
[IA_executionDate],
|
||||
[IA_schemaName],
|
||||
[IA_tableName],
|
||||
[IA_columnsName],
|
||||
[IA_isClustered],
|
||||
[IA_isUnique],
|
||||
[IA_includedColumns],
|
||||
[IA_isToBeDeleted],
|
||||
[IA_isToBeRecreated],
|
||||
[IA_expectedIndexName],
|
||||
[IA_foundIndexName],
|
||||
[IA_wasIndexFound],
|
||||
[IA_wasCreated],
|
||||
[IA_wasRenamed],
|
||||
[IA_wasDeleted],
|
||||
[IA_wasRecreated],
|
||||
[IA_includedColumnsMatch],
|
||||
[IA_actualColumns],
|
||||
[IA_actualIncludedColumns],
|
||||
[IA_statusMsg],
|
||||
[IA_indexOptions],
|
||||
[IA_reference]
|
||||
)
|
||||
SELECT
|
||||
NULL as [IA_executionDate],
|
||||
'dbo' as [IA_schemaName],
|
||||
'Criteria' as [IA_tableName],
|
||||
'CR_criteria_type' as [IA_columnsName],
|
||||
0 as [IA_isClustered],
|
||||
0 as [IA_isUnique],
|
||||
NULL as [IA_includedColumns],
|
||||
0 as [IA_isToBeRecreated],
|
||||
0 as [IA_isToBeRecreated],
|
||||
'NCIX_Criteria_COL_CR_criteria_type' as [IA_expectedIndexName],
|
||||
NULL as [IA_foundIndexName],
|
||||
0 as [IA_wasIndexFound],
|
||||
0 as [IA_wasCreated],
|
||||
0 as [IA_wasRenamed],
|
||||
0 as [IA_wasDeleted],
|
||||
0 as [IA_wasRecreated],
|
||||
NULL as [IA_includedColumnsMatch],
|
||||
NULL as [IA_actualColumns],
|
||||
NULL as [IA_actualIncludedColumns],
|
||||
NULL as [IA_statusMsg],
|
||||
'STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, SORT_IN_TEMPDB = OFF, FILLFACTOR =90' as IA_index_options,
|
||||
'OCTPDBA-414' AS [IA_reference]
|
||||
WHERE NOT EXISTS(
|
||||
SELECT 1
|
||||
FROM [Arizona].[upd].[IA_IndexAlignementActions] s
|
||||
WHERE [s].[IA_schemaName] = 'dbo'
|
||||
AND [s].[IA_tableName] = 'Criteria'
|
||||
AND [s].[IA_columnsName] = 'CR_criteria_type'
|
||||
AND [s].[IA_reference] = 'OCTPDBA-414'
|
||||
)
|
||||
|
||||
/* CR_master_ID */
|
||||
INSERT INTO [Arizona].[upd].[IA_IndexAlignementActions]
|
||||
(
|
||||
[IA_executionDate],
|
||||
[IA_schemaName],
|
||||
[IA_tableName],
|
||||
[IA_columnsName],
|
||||
[IA_isClustered],
|
||||
[IA_isUnique],
|
||||
[IA_includedColumns],
|
||||
[IA_isToBeDeleted],
|
||||
[IA_isToBeRecreated],
|
||||
[IA_expectedIndexName],
|
||||
[IA_foundIndexName],
|
||||
[IA_wasIndexFound],
|
||||
[IA_wasCreated],
|
||||
[IA_wasRenamed],
|
||||
[IA_wasDeleted],
|
||||
[IA_wasRecreated],
|
||||
[IA_includedColumnsMatch],
|
||||
[IA_actualColumns],
|
||||
[IA_actualIncludedColumns],
|
||||
[IA_statusMsg],
|
||||
[IA_indexOptions],
|
||||
[IA_reference]
|
||||
)
|
||||
SELECT
|
||||
NULL as [IA_executionDate],
|
||||
'dbo' as [IA_schemaName],
|
||||
'Criteria' as [IA_tableName],
|
||||
'CR_master_ID' as [IA_columnsName],
|
||||
0 as [IA_isClustered],
|
||||
0 as [IA_isUnique],
|
||||
NULL as [IA_includedColumns],
|
||||
0 as [IA_isToBeRecreated],
|
||||
0 as [IA_isToBeRecreated],
|
||||
'NCIX_Criteria_COL_CR_master_ID' as [IA_expectedIndexName],
|
||||
NULL as [IA_foundIndexName],
|
||||
0 as [IA_wasIndexFound],
|
||||
0 as [IA_wasCreated],
|
||||
0 as [IA_wasRenamed],
|
||||
0 as [IA_wasDeleted],
|
||||
0 as [IA_wasRecreated],
|
||||
NULL as [IA_includedColumnsMatch],
|
||||
NULL as [IA_actualColumns],
|
||||
NULL as [IA_actualIncludedColumns],
|
||||
NULL as [IA_statusMsg],
|
||||
'STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, SORT_IN_TEMPDB = OFF, FILLFACTOR =90' as IA_index_options,
|
||||
'OCTPDBA-414' AS [IA_reference]
|
||||
WHERE NOT EXISTS(
|
||||
SELECT 1
|
||||
FROM [Arizona].[upd].[IA_IndexAlignementActions] s
|
||||
WHERE [s].[IA_schemaName] = 'dbo'
|
||||
AND [s].[IA_tableName] = 'Criteria'
|
||||
AND [s].[IA_columnsName] = 'CR_master_ID'
|
||||
AND [s].[IA_reference] = 'OCTPDBA-414'
|
||||
)
|
||||
|
||||
/* CR_VGUID */
|
||||
INSERT INTO [Arizona].[upd].[IA_IndexAlignementActions]
|
||||
(
|
||||
[IA_executionDate],
|
||||
[IA_schemaName],
|
||||
[IA_tableName],
|
||||
[IA_columnsName],
|
||||
[IA_isClustered],
|
||||
[IA_isUnique],
|
||||
[IA_includedColumns],
|
||||
[IA_isToBeDeleted],
|
||||
[IA_isToBeRecreated],
|
||||
[IA_expectedIndexName],
|
||||
[IA_foundIndexName],
|
||||
[IA_wasIndexFound],
|
||||
[IA_wasCreated],
|
||||
[IA_wasRenamed],
|
||||
[IA_wasDeleted],
|
||||
[IA_wasRecreated],
|
||||
[IA_includedColumnsMatch],
|
||||
[IA_actualColumns],
|
||||
[IA_actualIncludedColumns],
|
||||
[IA_statusMsg],
|
||||
[IA_indexOptions],
|
||||
[IA_reference]
|
||||
)
|
||||
SELECT
|
||||
NULL as [IA_executionDate],
|
||||
'dbo' as [IA_schemaName],
|
||||
'Criteria' as [IA_tableName],
|
||||
'CR_VGUID' as [IA_columnsName],
|
||||
0 as [IA_isClustered],
|
||||
0 as [IA_isUnique],
|
||||
NULL as [IA_includedColumns],
|
||||
0 as [IA_isToBeRecreated],
|
||||
0 as [IA_isToBeRecreated],
|
||||
'NCIX_Criteria_COL_CR_VGUID' as [IA_expectedIndexName],
|
||||
NULL as [IA_foundIndexName],
|
||||
0 as [IA_wasIndexFound],
|
||||
0 as [IA_wasCreated],
|
||||
0 as [IA_wasRenamed],
|
||||
0 as [IA_wasDeleted],
|
||||
0 as [IA_wasRecreated],
|
||||
NULL as [IA_includedColumnsMatch],
|
||||
NULL as [IA_actualColumns],
|
||||
NULL as [IA_actualIncludedColumns],
|
||||
NULL as [IA_statusMsg],
|
||||
'STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, SORT_IN_TEMPDB = OFF, FILLFACTOR =90' as IA_index_options,
|
||||
'OCTPDBA-414' AS [IA_reference]
|
||||
WHERE NOT EXISTS(
|
||||
SELECT 1
|
||||
FROM [Arizona].[upd].[IA_IndexAlignementActions] s
|
||||
WHERE [s].[IA_schemaName] = 'dbo'
|
||||
AND [s].[IA_tableName] = 'Criteria'
|
||||
AND [s].[IA_columnsName] = 'CR_VGUID'
|
||||
AND [s].[IA_reference] = 'OCTPDBA-414'
|
||||
)
|
||||
|
||||
/* Criteria_ID */
|
||||
INSERT INTO [Arizona].[upd].[IA_IndexAlignementActions]
|
||||
(
|
||||
[IA_executionDate],
|
||||
[IA_schemaName],
|
||||
[IA_tableName],
|
||||
[IA_columnsName],
|
||||
[IA_isClustered],
|
||||
[IA_isUnique],
|
||||
[IA_includedColumns],
|
||||
[IA_isToBeDeleted],
|
||||
[IA_isToBeRecreated],
|
||||
[IA_expectedIndexName],
|
||||
[IA_foundIndexName],
|
||||
[IA_wasIndexFound],
|
||||
[IA_wasCreated],
|
||||
[IA_wasRenamed],
|
||||
[IA_wasDeleted],
|
||||
[IA_wasRecreated],
|
||||
[IA_includedColumnsMatch],
|
||||
[IA_actualColumns],
|
||||
[IA_actualIncludedColumns],
|
||||
[IA_statusMsg],
|
||||
[IA_indexOptions],
|
||||
[IA_reference]
|
||||
)
|
||||
SELECT
|
||||
NULL as [IA_executionDate],
|
||||
'dbo' as [IA_schemaName],
|
||||
'Criteria' as [IA_tableName],
|
||||
'Criteria_ID' as [IA_columnsName],
|
||||
0 as [IA_isClustered],
|
||||
1 as [IA_isUnique],
|
||||
NULL as [IA_includedColumns],
|
||||
0 as [IA_isToBeRecreated],
|
||||
0 as [IA_isToBeRecreated],
|
||||
'PK_Criteria_ID' as [IA_expectedIndexName],
|
||||
NULL as [IA_foundIndexName],
|
||||
0 as [IA_wasIndexFound],
|
||||
0 as [IA_wasCreated],
|
||||
0 as [IA_wasRenamed],
|
||||
0 as [IA_wasDeleted],
|
||||
0 as [IA_wasRecreated],
|
||||
NULL as [IA_includedColumnsMatch],
|
||||
NULL as [IA_actualColumns],
|
||||
NULL as [IA_actualIncludedColumns],
|
||||
NULL as [IA_statusMsg],
|
||||
'STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, SORT_IN_TEMPDB = OFF, FILLFACTOR =90' as IA_index_options,
|
||||
'OCTPDBA-414' AS [IA_reference]
|
||||
WHERE NOT EXISTS(
|
||||
SELECT 1
|
||||
FROM [Arizona].[upd].[IA_IndexAlignementActions] s
|
||||
WHERE [s].[IA_schemaName] = 'dbo'
|
||||
AND [s].[IA_tableName] = 'Criteria'
|
||||
AND [s].[IA_reference] = 'OCTPDBA-414'
|
||||
AND [s].[IA_columnsName] = 'Criteria_ID'
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -151,6 +305,6 @@ EXEC [upd].[alignIndexes] @in_debug = 01, -- int
|
||||
@in_dropUnreferencedIndexes = NULL; -- bit
|
||||
|
||||
SELECT *
|
||||
FROM upd.IA_IndexesAlignementActions;
|
||||
FROM upd.IA_IndexAlignementActions;
|
||||
|
||||
ROLLBACK TRANSACTION;
|
||||
Reference in New Issue
Block a user