156 lines
4.0 KiB
SQL
156 lines
4.0 KiB
SQL
USE Arizona;
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
EXEC [upd].[alignIndexes] @in_debug = 01, -- int
|
|
@in_dropUnreferencedIndexes = NULL; -- bit
|
|
|
|
SELECT *
|
|
FROM upd.IA_IndexesAlignementActions;
|
|
|
|
ROLLBACK TRANSACTION; |