Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
getur.srikanth@gmail.com
Yak Posting Veteran
77 Posts |
Posted - 2013-03-14 : 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
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-03-14 : 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 countSELECT 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) NonNullCountFROM INFORMATION_SCHEMA.columns--Chandu |
|
|
|
|
|
|
|