Untitled

 avatar
unknown
plain_text
a month ago
737 B
9
Indexable
-- CONTEXT GENERATION FOR COPILOT
-- Collects tables names, columns names
select
 '-- Table ' + t.table_schema + '.[' + t.table_name + '] (' + stuff(
  (
   select
    ', [' + c.column_name + '] ' + data_type + case
     when character_maximum_length is not null 
      then '(' + cast(character_maximum_length as varchar(10)) + ')'
     else ''
    end + case
     when is_nullable = 'NO' then ' not null'
     else ''
    end
   from
    information_schema.columns c
   where
    c.table_name = t.table_name
   order by
    ordinal_position for xml path('')
  ),1,2,''
 ) + ')' as TableDescription
from
 information_schema.tables t
where
 table_type = 'BASE TABLE'
order by
 t.table_schema,
 t.table_name 
Editor is loading...
Leave a Comment