SQL count rows in a table

前端 未结 6 1352
迷失自我
迷失自我 2020-12-15 15:28

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

6条回答
  •  北海茫月
    2020-12-15 16:03

    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.

提交回复
热议问题