| Author |
Topic  |
|
|
getur.srikanth@gmail.com
Yak Posting Veteran
74 Posts |
Posted - 03/14/2013 : 00:30:48
|
I am trying to find below information from the table in tabular format . I can getRows Count, Column Name and Attribute (DataType)
quote:
Database Name, Table Name, No.Of columns, No.Of Rows Count, Column name, Attribute (DataType), Min Value, Max Value, Non null count, Distinct count of the column
Example:
Database Name | Table Name | No.Of columns | No.Of Rows Count | Column name | Attribute (DataType)| Min Value | Max Value | Non null count | Distinct count of the column
SWISS_WIP | tbl_Files | 5 | 150 | Prod_Beg | int | 25 | 123212 | 123100 | 10
SWISS_WIP | tbl_Files | 5 | 150 | File_MD5| varchar | null | null | 12232| null
How can we do this? |
|
|
bandi
Flowing Fount of Yak Knowledge
India
1451 Posts |
Posted - 03/14/2013 : 02:55:22
|
From INFORMATION_SCHEMA.columns we can get following information:
Database Name, Table Name, No.Of columns, Column name, Attribute (DataType), Max Length, Non null count
SELECT Table_CATALOG DBName, Table_Name, MAX(Ordinal_position) OVER(Partition by Table_name) NoOfColumns, Column_name, Data_Type, Coalesce(CHARACTER_MAXIMUM_LENGTH, Numeric_precision, datetime_Precision) MaxLength, SUM( CASE WHEN IS_NULLABLE = 'NO' THEN 1 END) OVER(Partition by Table_name) NonNullCount FROM INFORMATION_SCHEMA.columns
-- Chandu |
 |
|
| |
Topic  |
|
|
|