feat: add ep.class = 1 filter

This commit is contained in:
Pavel
2025-08-26 18:05:08 +02:00
parent d3872ca8a3
commit d1e0c86a71
2 changed files with 13 additions and 10 deletions

View File

@@ -6,7 +6,6 @@ select c.name as columnName, t.name as dataType, c.object_id as objectId, c.is_i
m.definition as computedExpression, m.is_persisted as isPersisted, c.column_id as columnId, m.definition as computedExpression, m.is_persisted as isPersisted, c.column_id as columnId,
col.NUMERIC_PRECISION as numericPrecision, col.NUMERIC_PRECISION as numericPrecision,
col.NUMERIC_SCALE as numericScale, col.NUMERIC_SCALE as numericScale,
-- TODO only if version >= 2008
c.is_sparse as isSparse, c.is_sparse as isSparse,
ep.value as columnComment ep.value as columnComment
from sys.columns c from sys.columns c
@@ -16,7 +15,10 @@ INNER JOIN sys.schemas u ON u.schema_id=o.schema_id
INNER JOIN INFORMATION_SCHEMA.COLUMNS col ON col.TABLE_NAME = o.name AND col.TABLE_SCHEMA = u.name and col.COLUMN_NAME = c.name INNER JOIN INFORMATION_SCHEMA.COLUMNS col ON col.TABLE_NAME = o.name AND col.TABLE_SCHEMA = u.name and col.COLUMN_NAME = c.name
left join sys.default_constraints d on c.default_object_id = d.object_id left join sys.default_constraints d on c.default_object_id = d.object_id
left join sys.computed_columns m on m.object_id = c.object_id and m.column_id = c.column_id left join sys.computed_columns m on m.object_id = c.object_id and m.column_id = c.column_id
left join sys.extended_properties ep on ep.major_id = c.object_id and ep.minor_id = c.column_id and ep.name = 'MS_Description' left join sys.extended_properties ep on ep.major_id = c.object_id
and ep.minor_id = c.column_id
and ep.name = 'MS_Description'
and ep.class = 1 -- Add this filter for object/column level properties
where o.type = 'U' and o.object_id =OBJECT_ID_CONDITION and u.name =SCHEMA_NAME_CONDITION where o.type = 'U' and o.object_id =OBJECT_ID_CONDITION and u.name =SCHEMA_NAME_CONDITION
order by c.column_id order by c.column_id
`; `;

View File

@@ -11,4 +11,5 @@ inner join sys.schemas s on o.schema_id = s.schema_id
left join sys.extended_properties ep on ep.major_id = o.object_id left join sys.extended_properties ep on ep.major_id = o.object_id
and ep.minor_id = 0 and ep.minor_id = 0
and ep.name = 'MS_Description' and ep.name = 'MS_Description'
and ep.class = 1 -- Add this filter for object/column level properties
where o.object_id =OBJECT_ID_CONDITION and s.name =SCHEMA_NAME_CONDITION`; where o.object_id =OBJECT_ID_CONDITION and s.name =SCHEMA_NAME_CONDITION`;