SQL Server - How to Count Number of Rows and Columns in a table with Query?
sql server - To get total number of columns in a table in sql
Count Number of Rows in a Table
There are following ways to find number of rows from a table. Find the queries below :
select [TotalCount]=rows from sysindexes where indid <=1 and ID=object_ID('clients')
SELECT SUM(rows) FROM sys.partitions WHERE object_id = OBJECT_ID(N'dbo.clients')
AND index_id IN(0,1)
Count Number of Columns from a Table
There are following ways to finf number of column from a table. Find the queries below :
select count(*) from Employee.information_schema.columns where table_name = 'Employee'
select count(*),table_name from information_schema.COLUMNS
GROUP BY table_name