google-site-verification=ECX1M6_Vb39ty4VtQDXQce6wOjmPTxSettd3hTIZb9Q

SQL Server - How to Count Number of Rows and Columns in a table with Query?

random

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 :

Query 1

select [TotalCount]=rows from sysindexes where indid <=1 and ID=object_ID('clients')

database, sql server

Query 2

SELECT SUM(rows) FROM sys.partitions WHERE object_id = OBJECT_ID(N'dbo.clients')
AND index_id IN(0,1)

database, sql server

Count Number of Columns from a Table

There are following ways to finf number of column from a table. Find the queries below :

Query 1
 
select count(*) from Employee.information_schema.columns where table_name = 'Employee'

 
sql server, database

Query 2

select count(*),table_name from information_schema.COLUMNS
GROUP BY table_name

database, sql server


SQL Server - How to Count Number of Rows and Columns in a table with Query? Reviewed by Ravi Kumar on 5:15 PM Rating: 5

No comments:

All Rights Reserved by Etechpulse © 2012 - 2017

Contact Form

Name

Email *

Message *

Powered by Blogger.