From df40a8c5fe90fc3f1f2813e42add0a2ed42a96cf Mon Sep 17 00:00:00 2001 From: Brian Beaird Date: Mon, 3 May 2021 13:57:23 -0500 Subject: [PATCH] Remove join to index tables These are not used and can cause duplicate column records if a column is included in multiple indexes --- lib/queries/table_describe.sql | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/queries/table_describe.sql b/lib/queries/table_describe.sql index 037c24a8..5160cc58 100644 --- a/lib/queries/table_describe.sql +++ b/lib/queries/table_describe.sql @@ -66,20 +66,16 @@ FROM .INFORMATION_SCHEMA.TABLES st AND sc.TABLE_NAME = u.TABLE_NAME AND sc.COLUMN_NAME = u.COLUMN_NAME cross join t_name_cte r - INNER JOIN + INNER JOIN .sys.columns c ON c.name = sc.column_name INNER JOIN .sys.types t ON c.user_type_id = t.user_type_id INNER JOIN .sys.tables ta ON ta.name = r.table_name - LEFT OUTER JOIN - .sys.index_columns ic ON ic.object_id = c.object_id AND ic.column_id = c.column_id - LEFT OUTER JOIN - .sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id WHERE c.object_id = ta.object_id AND TABLE_TYPE = 'BASE TABLE' AND sc.TABLE_NAME = r.table_name AND (sc.TABLE_SCHEMA = '' or '' = '') AND (ta.schema_id = SCHEMA_ID('') or '' = '') - +