SELECT 'EXEC sys.sp_addextendedproperty ' + CASE WHEN B.Seq = 1 THEN 'N''1. Source IP'', '''', ' WHEN B.Seq = 2 THEN 'N''2. Source DB'', '''', ' WHEN B.Seq = 3 THEN 'N''3. Source Schema'', '''', ' WHEN B.Seq = 4 THEN 'N''4. Source Table'', '''', ' WHEN B.Seq = 5 THEN 'N''5. ETL Rule'', '''', ' WHEN B.Seq = 6 THEN 'N''6. Descriptions'', '''', ' END + 'N''SCHEMA'', N''' + TABLE_SCHEMA + ''', ' + 'N''TABLE'', N''' + TABLE_NAME + '''' from information_schema.tables CROSS JOIN ( SELECT 1 Seq UNION ALL SELECT 2 Seq UNION ALL SELECT 3 Seq UNION ALL SELECT 4 Seq UNION ALL SELECT 5 Seq UNION ALL SELECT 6 ) B WHERE TABLE_NAME = '企覈'
-- 企 貉殊 レ煙 伎. -- IP -- DB -- Schema -- 企 -- 貉 -- ETL Rule -- Value Rule SELECT 'EXEC sys.sp_addextendedproperty ' + CASE WHEN B.Seq = 1 THEN 'N''1. Source IP'', '''', ' WHEN B.Seq = 2 THEN 'N''2. Source DB'', '''', ' WHEN B.Seq = 3 THEN 'N''3. Source Schema'', '''', ' WHEN B.Seq = 4 THEN 'N''4. Source Table'', '''', ' WHEN B.Seq = 5 THEN 'N''5. Source Column'', '''', ' WHEN B.Seq = 6 THEN 'N''6. ETL Rule'', '''', ' WHEN B.Seq = 7 THEN 'N''7. Value Rule'', '''', ' END + 'N''SCHEMA'', N''' + TABLE_SCHEMA + ''', ' + 'N''TABLE'', N''' + TABLE_NAME + ''', ' + 'N''COLUMN'', N''' + COLUMN_NAME + '''' FROM INFORMATION_SCHEMA.COLUMNS CROSS JOIN ( SELECT 1 Seq UNION ALL SELECT 2 Seq UNION ALL SELECT 3 Seq UNION ALL SELECT 4 Seq UNION ALL SELECT 5 Seq UNION ALL SELECT 6 Seq UNION ALL SELECT 7) B --WHERE TABLE_NAME = '企覈'
select distinct s.name as [schema] , t.name as [table name] , c.name as [column name] , ep.name as [property name] , ep.value as [business definition] from sys.tables as t inner join sys.schemas as s on s.schema_id = t.schema_id inner join sys.columns as c on t.object_id = c.object_id inner join sys.extended_properties as ep on ep.major_id = t.object_id and ep.minor_id=c.column_id --where ep.name in ('1. Source IP')