Latest

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


No comments:

All Rights Reserved by Etechpulse © 2015 - 2016
Powered By Blogger

Contact Form

Name

Email *

Message *

Powered by Blogger.