SQL count rows in a table

0 votes
I need to submit a SQL query to a database to determine the number of rows in a table. I could use a SELECT to retrieve all the rows in the table and then count them, but I don't enjoy doing things this way. Is there any method to query the SQL server for the amount of rows in a table?
Feb 21 in Database by Vaani
• 7,020 points
157 views

1 answer to this question.

0 votes

A fast way of doing this would be to use the following query but it is often not accurate

select sum([rows])
from sys.partitions
where id=id('tablename')
 and index_id in (0,1)

answered Feb 21 by Neha
• 8,940 points

Related Questions In Database

0 votes
2 answers

What are the ways to get the count of records in a table

With the help of the SQL count ...READ MORE

answered Aug 20, 2020 in Database by Okugbe
• 280 points
2,477 views
0 votes
2 answers

How to select the nth row in a SQL database table?

SELECT * FROM ( SELECT ID, NAME, ROW_NUMBER() ...READ MORE

answered Apr 23, 2020 in Database by anand
• 140 points
18,946 views
0 votes
1 answer

Inserting multiple rows in a single SQL query?

In SQL Server 2008, multiple rows can ...READ MORE

answered Feb 10 in Database by Vaani
• 7,020 points
160 views
0 votes
0 answers
0 votes
1 answer

How to connect to sql server from power Bi?

Hi, Follow these steps to connect to SQL ...READ MORE

answered Mar 22, 2019 in Power BI by Cherukuri
• 33,050 points
760 views
0 votes
1 answer

How to connect to sql server from Tableau?

Hi, Follow these steps to connect to sql ...READ MORE

answered Mar 22, 2019 in Tableau by Cherukuri
• 33,050 points
1,103 views
0 votes
1 answer

How Can I use "Date" Datatype in sql server?

There's problem in all of them and ...READ MORE

answered Feb 9 in Database by Neha
• 8,940 points
273 views
0 votes
1 answer

How to do version control for SQL Server database?

Not only can you compare objects at ...READ MORE

answered Feb 15 in Database by Neha
• 8,940 points
84 views
0 votes
1 answer

How to rename a column in a database table using SQL?

For SQL Server, use sp_rename USE AdventureWorks; GO EXEC sp_rename 'Customers.CustomerTerritory.TerritoryID', ...READ MORE

answered Feb 9 in Database by Neha
• 8,940 points
147 views
0 votes
1 answer

Ordering by the order of values in a SQL IN() clause

Use MySQL's FIELD() function: SELECT name, description, ... FROM ... WHERE id ...READ MORE

answered Feb 4 in Database by Neha
• 8,940 points
1,549 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP