Collection NS Database Structure

Collection NS Database Structure
networkchic's picture

If you've ever wondered what a collection structure of a NS Database looked like wonder no more! Ponder this a bit...

select
[table_name] as [Table Name],
[column_name] as [Column Name],
case [data_type]
 when 'varchar' then [data_type] + '(' + cast([character_maximum_length] as varchar) + ')'
 when 'nvarchar' then [data_type] + '(' + cast([character_maximum_length] as nvarchar) + ')'
 else [data_type]
end as [Data Type],
case [is_nullable]
 when 'No' then 'No'
 else 'Yes'
end as [Nullable],
isnull([column_default], '') as [Default Value],
isnull(cast([numeric_precision] as nvarchar),'') as [Precision],
isnull(cast([numeric_precision_radix] as nvarchar),'') as [Precision Radix],
isnull([collation_name],'') as [Collation Name]
from information_schema.[columns]
where [table_catalog]  like '%'
  and [table_schema] like 'dbo'
  and [table_name]   like '%'
  and [column_name] like '%'
  and [data_type]    like '%'
order by [table_name], [ordinal_position] 

3.384615
Average: 3.4 (26 votes)