[use database name]
select [SchemaName],[TableName],[RowCount], ColumnCount
from (select s.name [SchemaName], t.name [TableName], sum(st.row_count) [RowCount]
from sys.tables t
inner join sys.schemas s on t.schema_id = s.schema_id
inner join sys.indexes i on t.object_id = i.object_id
inner join sys.dm_db_partition_stats st on t.object_id = st.object_id and i.index_id = st.index_id
where i.index_id < 2
group by s.name, t.name
) t_r
inner join
(select TABLE_NAME, COUNT(TABLE_NAME) ColumnCount from INFORMATION_SCHEMA.COLUMNS group by TABLE_NAME) t_c
on t_r.TableName = t_c.TABLE_NAME
Output:
Riddhi ValechaPosted Feb 24, 2016, 12:11 AM
Hi... Riddhi Valecha from C# Corner ... Sir I need your help in making an SQL Query... I have already posted it in the forums - http://www.c-sharpcorner.com/forums/sql-query-pls-help3 Sir, Please guide me ... I am failing in making this query...
John MaddenPosted Nov 11, 2011, 10:20 AM
Good stuff