SQL 计算表中的行数

2021-12-30 00:00:00 rows count sql-server database-table

我需要向数据库发送一个 SQL 查询,该查询告诉我一个表中有多少行.我可以使用 SELECT 获取表中的所有行,然后对它们进行计数,但我不喜欢这样做.有没有其他方法可以向SQL Server询问表中的行数?

I need to send a SQL query to a database that tells me how many rows there are in a table. I could get all the rows in the table with a SELECT and then count them, but I don't like to do it this way. Is there some other way to ask the number of the rows in a table to the SQL server?

推荐答案

Yes, SELECT COUNT(*) FROM TableName

相关文章