SQL count rows in a table
问题 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? 回答1: Yes, SELECT COUNT(*) FROM TableName 回答2: select sum([rows]) from sys.partitions where object_id=object_id('tablename') and index_id in (0,1) is very fast but very rarely inaccurate. 回答3: Use This Query :